lvcpp lvcpp - 3 months ago 22
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.get("https://www.rec-registry.gov.au/rec-registry/app/public/lgc-register")
driver.find_elements_by_tag_name('button')[4].click() # status
# show the needed elements for the next action,
# enter(open the door) to the div.ms-drop 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

driver.save_screenshot('lgc1.png')

Answer

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

driver.find_element_by_id('search-submit').click() 
Comments