如何填写此表单https://fedresurs.ru/messages/IsSearching?输入“消息类型”。提前做到了:
def get_list(n):
timeout = 3
try:
element_present = EC.presence_of_element_located(
(By.XPATH, '//li[@class="active"]/a/span[text()="{}"]'.format(n)))
WebDriverWait(driver, timeout).until(element_present)
except TimeoutException:
print("Timed out waiting for page to load")
lst_divs = driver.find_elements_by_class_name('display-field.message-in-list')
lst_as = driver.find_elements_by_xpath('//div[starts-with(@id, "ctl00_MainContent_lvMessageList_ctrl")]')
for d, a in zip(lst_divs, lst_as):
print('\t{} :: {}'.format(d.text, a.text))
driver = webdriver.Chrome(executable_path=r"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
url = 'http://fedresurs.ru/messages/IsSearching'
driver.get(url)
driver.find_element_by_id('ctl00_MainContent_sfMessageType_txtObjectName').click()
driver.find_element_by_id('ctl00_MainContent_sfMessageType_txtObjectName').send_keys('Сообщение о выпуске независимой гарантии')
# time.sleep(5)
# s = driver.find_element_by_xpath('//*[@id="ctl00_MainContent_btnSearch"]') # Кнопка поиск
# s.click()
现在它无法正常工作。
答案 0 :(得分:0)
尝试使用以下代码执行搜索
/^$/
答案 1 :(得分:0)
有一种替代方法可以通过执行javascript
来发送文本。试试这个 -
driver.execute_script("document.getElementById('ctl00_MainContent_sfMessageType_txtObjectName').value='Сообщение о выпуске независимой гарантии'")
它为你的场景而努力。