Frage

I'm trying to test a site like sample and get different outcomes when clicking a button. When running selenium webdriver's --firefox and chrome-- I get redirected after this click:

@driver.find_element(css: "#shipping-zip-form .button.small").click

However, if i go to the site and run the following command in the console, I do not get redirected.

jQuery('#shipping-zip-form .button.small').click();

What is causing redirects to the homepage when running on through selenium? A thread.sleep command won't work and wait_until isn't working either. My guess is that something is happening too fast...

War es hilfreich?

Lösung

The base url in selenium was https. The button click was firing off an ajax request that wasn't returning the referer. Once the base url was switched to http, the button click worked fine and there was no redirect to the base url.

"If a website is accessed from a HTTP Secure (HTTPS) connection and a link points to anywhere except another secure location, then the referer field is not sent." --https://www.rfc-editor.org/rfc/rfc2616#section-15.1.3

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top