У браузера Safari проблемы с Selenium - PullRequest
1 голос
/ 21 июня 2020
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Safari()  
driver.get("https://www.instagram.com/")
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='username']"))).send_keys("username")
driver.find_element_by_xpath("//input[@name='password']").send_keys("password")
driver.find_element_by_xpath("//button/div[text()='Log In']").click()

Выполните приведенный выше код в надежде, что он, наконец, заработает, и заполните страницу входа в Instagram. Однако он возвращает эту ошибку ...

---------------------------------------------------------------------------
TimeoutException                          Traceback (most recent call last)
<ipython-input-1-d0556cce8de8> in <module>
      6 driver = webdriver.Safari()
      7 driver.get("https://www.instagram.com/")
----> 8 WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='username']"))).send_keys("username")
      9 driver.find_element_by_xpath("//input[@name='password']").send_keys("password")
     10 driver.find_element_by_xpath("//button/div[text()='Log In']").click()

/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/support/wait.py in until(self, method, message)
     78             if time.time() > end_time:
     79                 break
---> 80         raise TimeoutException(message, screen, stacktrace)
     81 
     82     def until_not(self, method, message=''):

TimeoutException: Message: 

Пробовал это на Chrome, но я все равно получил то же сообщение. Есть какие-нибудь подсказки относительно того, что происходит? Ниже HTML для блока имени пользователя.

<label class="f0n8F "><span class="_9nyy2">Phone number, username, or email</span><input aria-label="Phone number, username, or email" aria-required="true" autocapitalize="off" autocorrect="off" maxlength="75" name="username" type="text" class="_2hvTZ pexuQ zyHYP" value=""></label>

Ниже HTML для блока пароля.

<label class="f0n8F "><span class="_9nyy2">Password</span><input aria-label="Password" aria-required="true" autocapitalize="off" autocorrect="off" name="password" type="password" class="_2hvTZ pexuQ zyHYP" value=""></label>
...