Login button works with firefox but not with phantomjs

189 views Asked by At

I have a login form submission button that looks like this:

<input type="button" name="BUTTON1" value="Login" title="Login" class="Bottone1" onclick="if( gx.evt.jsEvent(this)) {gx.evt.execEvt('EENTER.',this);} else return false;" onfocus="gx.evt.onfocus(this, 26,'',false,'',0)">

In my ruby script using watir-webdriver and firefox backend this code works fine:

browser.button(:name => "BUTTON1").click

Unfortunately if I switch to phantomjs backend nothing happens using this code and the screenshot shows me that I'm stuck in the same page.

=== UPDATE:

It looks like the button was triggered but the redirect didn't work. Actually, if after clicking the button I manually go to the desired page it lets me in, so the form is submitted.

1

There are 1 answers

0
Pippo On

I can't explain why exactly, but phantomjs was a bit buggy for me as well... the same issue... I boiled it to 2 patterns:

1:. Timing issue, you need to add sleeps prior to clicking to give time for the element/page to load (even visible/load checks would fail on me)

2:. .click action for some reason wouldn't trigger the event... I had to add something like the below to workaround:

3.times do 
  element.visible? ? element.click : break
end

last case scenario you could try something similar as the suggestion in your original comment:

element.trigger('click')...