from selenium import webdriver
from selenium.webdriver.common.keys import Keys
chromedriver = 'C:\\chromedriver.exe'
browser = webdriver.Chrome(chromedriver)
browser.get('http://www.example.com')
username = browser.find_element_by_id('username')
password = browser.find_element_by_id('password')
username.send_keys('username')
password.send_keys('password')
browser.find_element_by_id('submit').click()
我想点击下载按钮(右下第二个)。
请帮帮我!!以下代码不起作用:
browser.find_elements_by_id('//input[@value="EE"]').click()
答案 0 :(得分:2)
取决于您在该页面上有多少类似的链接尝试:
browser.find_element_by_partial_link_text(
'https://earthexplorer.usgs.gov/download/').click()
了解更多定位选项see the docs
另请注意,您必须添加等效于Access to file download dialog in Firefox的Chrome,以避免下载对话框