简体   繁体   English

使用Selenium Python在页面中查找特定文本

[英]Finding a specific text in a page using selenium python

I'm trying to find a specific text from a page https://play.google.com/store/apps/details?id=org.codein.filemanager&hl=en using selenium python. 我正在尝试使用硒python从页面https://play.google.com/store/apps/details?id=org.codein.filemanager&hl=zh_CN中查找特定文本。 I'm looking for the element name - current version from the above url. 我正在寻找元素名称-上述网址的当前版本。 I used the below code 我用下面的代码

 browser = webdriver.Firefox() # Get local session of firefox
 browser.get(sampleURL) # Load page

 elem = browser.find_elements_by_clsss_name("Current Version") # Find the query box
 print elem;
 time.sleep(2) # Let the page load, will be added to the API
 browser.close()

I don't seem to get the output printed. 我似乎没有得到输出打印。 Am I doing anything wrong here? 我在这里做错什么吗?

There is no class with name "Current Version". 没有名为“当前版本”的类。 If you want to capture the version number that is below the "Current Version" text, the you can use this xpath expression: 如果要捕获“当前版本”文本下方的版本号,则可以使用此xpath表达式:

browser.find_element_by_xpath("//div[@itemprop='softwareVersion']")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM