lvcpp lvcpp - 6 months ago 51
Python Question

browser automation with PhantomJS and Firefox, support of the different browsers

Why the code works with webdriver.Firefox but do not work with webdriver.PhantomJS ?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.PhantomJS() # why not?
# driver.set_window_size(1400, 1050)

# driver = webdriver.Firefox() # Firefox 45, works correctly

driver.find_elements_by_tag_name('button')[4].click() # status
# show the needed elements for the next action,
# enter(open the door) to the area
driver.find_elements_by_class_name('ms-drop')[4].find_element_by_css_selector('ul>li:nth-child(12)').click() # registered
driver.find_element_by_id('search-submit').send_keys(Keys.RETURN) # search



You should try using .click() for click purpose instead of send_keys(Keys.RETURN) as below :