[英]How do I “click” with python selenium when object is not callable? Do I need javascript here, and how?
div = soup.find('div',{'class':'apply_button'})
div.input.click()
This gets the correct tag, but returns 'NoneType' object is not callable SendKeys does not work either.这将获得正确的标签,但返回 'NoneType' object is not callable SendKeys 也不起作用。
I don't understand javascript.我不明白 javascript。 Do I need to execute it to enable the button?我需要执行它来启用按钮吗? Or is there some simple way to enable the button so that it can be clicked?还是有一些简单的方法可以启用按钮以便可以单击它?
<div class="main_content"> <p> <script type="text/javascript">dw(system_help_reboot); </script>Click the button below to restart the device. </p> <div class="apply_button"> <label id="button_reboot"> <script type="text/javascript">create_button(system_label_reboot,"reboot_apply_button"); </script> <span class="button_wrapper" id="span_reboot_apply_button"> <input class="button_dialog" id="reboot_apply_button" type="button" value="Reboot"/> </span> </label> </div> </div>
It's not possible to run Javascript clicks through BeautifulSoup.不可能通过 BeautifulSoup 运行 Javascript 点击。 But, if you want to use just Python / Selenium, you can JS click like this:但是,如果你只想使用 Python / Selenium,你可以像这样点击 JS:
elementToClick = driver.find_element_by_xpath("//div[@class='apply_button']")
driver.executeScript("arguments[0].click();", elementToClick)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.