[英]How to find element by visible text using selenium?
I'm trying to find a text and click, but I don't know what's going on nothing that I try is working.我正在尝试查找文本并单击,但我不知道发生了什么我尝试的任何工作都没有。
I've already tried:我已经尝试过:
driver.find_element(By.XPATH("//*[contains(text(),'Retenção colocada pelo sistema para reter documentos fiscais que requerem confirmação eletrônica. ')]")).click()
and和
driver.find_elements_by_xpath("//*[contains(text(), 'Retenção colocada pelo sistema para reter documentos fiscais que requerem confirmação eletrônica. ')]")
I get this error: 'str' object is not callable我收到此错误:'str' object 不可调用
Instead of driver.find_element(By.XPATH("//*[contains(text(),'Retenção colocada pelo sistema para reter documentos fiscais que requerem confirmação eletrônica. ')]")).click()
Try而不是
driver.find_element(By.XPATH("//*[contains(text(),'Retenção colocada pelo sistema para reter documentos fiscais que requerem confirmação eletrônica. ')]")).click()
试试
driver.find_element(By.XPATH, "//*[contains(text(),'Retenção colocada pelo sistema para reter documentos fiscais que requerem confirmação eletrônica.')]").click()
If you are searching by partial text - the best practice will be to ignore characters like dot (.), semi-colon (;) or apostrophe (').如果您按部分文本搜索 - 最佳做法是忽略点 (.)、分号 (;) 或撇号 (') 等字符。
driver.find_element(By.XPATH, "//*[contains(text(),'Retenção colocada pelo sistema para reter documentos fiscais')]").click()
Also ignore some of the words, up to 8 or 9 words is more than enough.也忽略一些单词,最多八九个单词就绰绰有余了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.