python - 无法在 Python Selenium 上提交/单击/执行 Javascript WebForm
问题描述
我想在填写 From 和 To 日期后单击 Search 按钮。然后,框下方的交易将刷新以显示过滤后的交易。它只是不会过滤交易。我无法让 Selenium 单击“搜索”按钮。我尝试了很多方法(请参阅下面我尝试执行的代码和屏幕截图)但没有成功。
任何帮助,将不胜感激。
<div class="ButtonPanel">
<div class="left">
<a id="ctl00_BodyPlaceHolder_lbCancel" class="button button_ui button_gray icon icon_cancel lbCancel" href="javascript:__doPostBack('ctl00$BodyPlaceHolder$lbCancel','')"><i aria-hidden="true" role="presentation" tabindex="-1"></i><strong>Cancel</strong></a>
</div>
<div class="right">
<a id="ctl00_BodyPlaceHolder_lbSearch" class="button button_ui button_yellow icon icon_search lbSearch" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$BodyPlaceHolder$lbSearch", "", true, "Search", "", false, true))"><i aria-hidden="true" role="presentation" tabindex="-1"></i><strong>Search</strong></a>
</div>
</div>
这些是尝试过的代码,但没有一个可以“搜索”来过滤交易:
driver.find_element_by_css_selector("a.ctl00_BodyPlaceHolder_lbSearch.button.button_ui.button_yellow.icon.icon_search.lbSearch").click()
driver.find_element_by_id("ctl00_BodyPlaceHolder_lbSearch").click()
driver.find_element_by_css_selector("div.right a#ctl00_BodyPlaceHolder_lbSearch.button.button_ui.button_yellow.icon.icon_search.lbSearch").click()
driver.find_element_by_xpath("//a[@id ='ctl00_BodyPlaceHolder_lbSearch']").click()
driver.find_element_by_xpath("//i[@role ='presentation']").click()
driver.find_element_by_xpath("//i[@aria-hidden ='true']").click()
driver.find_element_by_xpath("//i[@role ='presentation' and @tabindex = '1']").click()
driver.find_element_by_id("ctl00_BodyPlaceHolder_lbSearch").submit()
driver.find_element_by_xpath("//a[@id ='ctl00_BodyPlaceHolder_lbSearch']").submit()
driver.find_element_by_link_text("Search").submit()
driver.find_element_by_link_text("Search").click()
driver.execute_script('WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$BodyPlaceHolder$lbSearch", "", true, "Search", "", false, true))')
driver.find_element_by_xpath("//a[@id = 'ctl00_BodyPlaceHolder_lbSearch']/i[@role ='presentation']").click()
driver.find_element_by_xpath("//a[@class = 'button button_ui button_yellow icon icon_search lbSearch']/i[@role ='presentation']").click()
driver.find_elements_by_xpath("//i[@role ='presentation'][5]").click()
search_date = driver.find_elements_by_xpath("//i[5]")
search_date.click()
driver.find_element_by_xpath("//a[i/@role ='presentation']").click()
driver.find_element_by_xpath("//a/@id='ctl00_BodyPlaceHolder_lbSearch'[i/@role ='presentation']").click()
driver.find_element_by_xpath(".//div[@class='ButtonPanel']/div[@class='right']/a[@id='ctl00_BodyPlaceHolder_lbSearch']/i[@role='presentation']")
driver.find_element_by_xpath(".//div[@class='ButtonPanel']/div[@class='right']/a[@id='ctl00_BodyPlaceHolder_lbSearch']").click()
driver.find_element_by_xpath(".//div[@class='ButtonPanel']/div[@class='right']/a[@class='button button_ui button_yellow icon icon_search lbSearch']").click()
river.find_element_by_link_text("Search").click()
解决方案
推荐阅读
- angular - Angular 将组件从模块传递到 App 模块中的另一个模块
- java - Junit5 测试报告器
- java - 带有配置的资源“attr/strokeWidth”的重复值
- azure - 删除 /var/lib/azsec 下的文件是否安全?Azure 虚拟机
- java - app:compileDebugJavaWithJavac , react-native app 编译失败
- java - java.io.IOException:无法运行程序“curl”CreateProcess error=2,Impossibile trovare il file specificato
- xml - 通过 Grok Exporter 读取 XML 文件
- windows - 有没有办法在 Minikube 目录和本地 Windows 10 目录之间共享 Kubernetes 卷?
- node.js - 节点js获取状态
- nosql - 根据以前的记录检索文档结构