Selenium - Выбор календаря - Выберите текущий день NoSuchElementException Python 3 - PullRequest
0 голосов
/ 30 августа 2018

Проблема была с моим методом навигации по странице. Я должен выбрать актуальный календарь, а затем выбрать текущую дату. Код ниже является обновленным и правильным кодом.

from selenium import webdriver
import time


driver = webdriver.Firefox()

#navigates to website 
driver.get('https://www.sosnc.gov/online_services/search/by_title/_Business_Registration_changes')

#select calendar
driver.find_element_by_xpath('/html/body/div[2]/main/article/div/form/article/section/div/div[2]/label').click()
time.sleep(3)

#select current calendar date
driver.find_element_by_css_selector('.ui-datepicker-today').click()
time.sleep(2)

#select and click search button
driver.find_element_by_xpath('//*[@id="Search"]').click()

1 Ответ

0 голосов
/ 12 сентября 2018

Я обновил код выше до правильного кода с объяснением решения.

from selenium import webdriver
import time


driver = webdriver.Firefox()

#navigates to website 
driver.get('https://www.sosnc.gov/online_services/search/by_title/_Business_Registration_changes')

#select calendar
driver.find_element_by_xpath('/html/body/div[2]/main/article/div/form/article/section/div/div[2]/label').click()
time.sleep(3)

#select current calendar date
driver.find_element_by_css_selector('.ui-datepicker-today').click()
time.sleep(2)

#select and click search button
driver.find_element_by_xpath('//*[@id="Search"]').click()
...