from selenium import webdriver
# executable path should be the place where chrome driver is on the computer
driver = webdriver.Chrome(executable_path= '/users/user/Downloads/Chromedriver')
# This line tells the driver to go to the help section of chrome
driver.get('chrome://help')
# Because certain elements are stored in another Iframe, you must switch to this particular Iframe which is called 'help' in this case.
driver.switch_to.frame(driver.find_element_by_name('help'))
# retrive the text of the element and store it's text in a variable.
version_string = driver.find_element_by_id('version-container').text
# Now you can easily print it.
print version_string
您可以使用seleniumwebdriver轻松地完成此任务,在本例中,我们将提取Google Chrome的版本号。你知道吗
下面是示例代码,注释解释了每个步骤:
相关问题 更多 >
编程相关推荐