1
votes

I am having difficulties when using PhantomJs in my Watir webdriver.

Here is my code when selecting an element:

signInButton = driver.button text: 'Sign In'
signInButton.wait_until_present
signInButton.exists?
signInButton.click

It works fine when using Chrome but does not work when using PhantomJs.

This is how I start using Chrome:

@@driver = Watir::Browser.new :chrome, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate --disable-notifications --start-maximized]
@@driver.driver.manage.timeouts.implicit_wait = 100 # seconds

This is how I start using PhantomJs:

args = %w{--ignore-ssl-errors=true}
@@driver = Watir::Browser.new :phantomjs, :args => args
@@driver.driver.manage.timeouts.implicit_wait = 100 # seconds

Please help and thanks in advance.

1
You should attempt to avoid using text as a locator when possible in favor of browser.button in this case, or browser.button(type: 'submit'). Additionally, you should not use implicit_wait with Watir. Watir by default does the waiting for you and implicit waits will just get in your way. - titusfortner

1 Answers

0
votes

PhantomJS is being deprecated in Watir & Selenium. Chromedriver has for a while been significantly faster, and now has implemented a Headless mode if you really need to have it be headless. Just add --disable-gpu and --headless to your array of switches.