Коллеги, доброго дня.
Бьюсь с запуском скрипта на linux сервере без X.
Для отладки и удобства писал в PyCharm, там все работает как часы.
Скопировал все на сервер, где это будет работать, и при попытки запуска вываливает ошибки вида:
Traceback (most recent call last):
File "test.py", line 24, in <module>
EC.presence_of_element_located((By.ID, "login"))
File "/usr/lib/python2.7/site-packages/selenium/webdriver/support/wait.py", line 71, in until
value = method(self._driver)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/support/expected_conditions.py", line 63, in __call__
return _find_element(driver, self.locator)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/support/expected_conditions.py", line 401, in _find_element
raise e
selenium.common.exceptions.UnexpectedAlertPresentException: Alert Text: None
Message:
или
Traceback (most recent call last):
File "test.py", line 19, in <module>
driver = webdriver.Firefox() # type:
File "/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 162, in __init__
keep_alive=True)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
Сам скрипт выглядит так:
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest, time, re
##LOGIN SITE
driver = webdriver.Firefox() # type:
driver.get("https://MYDOMAIN.LOCAL")
try:
elemLogin = WebDriverWait (driver, 10).until(
EC.presence_of_element_located((By.ID, "login"))
)
elemLogin.send_keys("guest")
driver.find_element_by_id("password").send_keys("Qwerty123")
driver.find_element_by_id("submitter").click()
except TimeoutException:
print("Сould not login")
time.sleep(5)
driver.switch_to_frame('menu')
try:
elemApp = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "_application_settings"))
)
elemApp.click()
except TimeoutException:
print("Not view Settings")
try:
elemLogout = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "//a[4]/i"))
)
elemLogout.click()
except TimeoutException:
print("Сould not logout")
driver.quit()
Подскажите что я делаю не так.