我點擊日期框,清除值並請求新數據。我試圖點擊日期字段,但我沒有看到日曆彈出,因爲它應該。我該如何解決這個問題?硒問題
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path='/home/usch/Desktop/PyCharm/Project/geckodriver')
#load up website
driver.get('https://www.fxstreet.com/economic-calendar')
time.sleep(10)
#close popup
popup = driver.find_element_by_xpath('//button[@aria-label="Close Modal"]')
popup.click()
#click filter options
filter = driver.find_element_by_id('fxit-advlink')
filter.click()
#set start and end time
startDate = driver.find_element_by_xpath("//input[contains(@id,'fxit-start-advanced')]")
startDate.send_keys(Keys.ENTER)
startDate.clear()
startDate.send_keys("01/02/2017")
startDate.send_keys(Keys.ENTER)
endDate = driver.find_element_by_xpath("//input[contains(@id,'fxit-end-advanced')]")
endDate.send_keys(Keys.ENTER)
endDate.clear()
endDate.send_keys("06/01/2017")
endDate.send_keys(Keys.ENTER)
#driver.switch_to.default_content()
#select countries
#select data type
category = driver.find_element_by_xpath('//a[@class="fxst-selectall" and @data-name="fxst-category"]').click()
#refresh your results
refresh = driver.find_element_by_xpath('//a[@id="fxit-filterbutton"]').click()
日曆顯示和消失非常快因爲它是硒它必須讓事情變得快速,但是你是否想等待一段時間? –
即使我一行一行地運行,日曆不會彈出 –
我添加time.sleep(5)每次設置後,它彈出正確,所以我不認爲它與您的代碼 –