I've got autotests, using Chromedriver, and locally they work well in a graphical mode. We're gonna run them on ubuntu server without graphic, so I need to use another driver or emulate X-server. I'm trying to use PhantomJs. Below is what I've done:
1) Downloaded the latest 2.1.1 PhantomJs drive and put it in the PATH variable. 2) Tests are working using Selenium 3.3.1, pytest 2.9.0 3) Changed the driver in my tests:
#from selenium.webdriver.chrome.webdriver import WebDriver
from selenium.webdriver.phantomjs.webdriver import WebDriver
from fixture.session import SessionHelper
from fixture.new_house import NewHouseHelper
from fixture.rooms import RoomsHelper
class Application:
def __init__(self):
self.wd = WebDriver()
self.wd.implicitly_wait(20)
self.wd.maximize_window()
# Помощник получает ссылку на объект класса application
self.session = SessionHelper(self)
self.new_house = NewHouseHelper(self)
self.rooms = RoomsHelper(self)
def is_valid(self):
try:
self.wd.current_url
return True
except:
return False
def open_home_page(self):
wd = self.wd
wd.get("my_url")
def destroy(self):
self.wd.quit()
So, when i run tests, I see:
E selenium.common.exceptions.NoSuchElementException: Message: {"errorMessage":"Unable to find element with id 'LoginLogin'","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"91","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:62719","User-Agent":"Python-urllib/3.5"},"httpVersion":"1.1","method":"POST","post":"{\"using\": \"id\", \"sessionId\": \"0d199430-19b3-11e7-8517-21c763e93303\", \"value\": \"LoginLogin\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/0d199430-19b3-11e7-8517-21c763e93303/element"}}
E Screenshot: available via screen
..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:193: NoSuchElementException
What I did wrong? Maybe it's the problem with this version of Phantom? Would be great to hear any ideas to solve the problem.