событие щелчка селена не работает с Python - PullRequest
0 голосов
/ 30 октября 2019

Я хочу, чтобы эта де-программа нажала на вход веб-сайта. Я нахожу элемент с именем класса.

Я пытался изменить имя класса, но не работает.

from selenium import webdriver 
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.common.by import By 
import time 

# Open Chrome
driver = webdriver.Chrome('C:/xampp/htdocs/pegasus/chromedriver') 

# Going to website
driver.get("https://www.flypgs.com/en")

# Select button by class name and click on it.
frombtn = driver.find_element_by_class_name('select2-selection')
frombtn.click()

searchbtn = driver.find_element_by_class_name("select2-search__field")
searchbtn.click()

inputfrom = input('From: ')
searchbtn.send_keys(inputfrom)

tobtn = driver.find_element_by_xpath("//span[@class='select2-selection select2-selection--single']")
tobtn.click()

tosrcbtn = driver.find_element_by_xpath("//input[@class='select2-search__field']")
tosrcbtn.click()

toinput = input('To: ')
tobtn.send_keys(toinput)

time.sleep(1000000)

Это ошибка:

Exception has occurred: WebDriverException
Message: unknown error: Element <span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="true" tabindex="0" aria-labelledby="select2-8xub-container" aria-owns="select2-8xub-results" aria-activedescendant="select2-8xub-result-qvfa-AMS">...</span> is not clickable at point (144, 416). Other element would receive the click: <input class="select2-search__field" type="search" tabindex="0" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" maxlength="25">
(Session info: chrome=77.0.3865.120)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.17763 x86_64)
File "C:\xampp\htdocs\pegasus\app.py", line 25, in <module>
tobtn.click()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...