I have a web page. When I open that web page first it ask for server authentication. After providing the server authentication it allows me to navigate the web site. I have to automate that web page but because of the server authentication I am unable to move forward. How I can handle this server authentication in Geb or Web Driver
相关问题
- Selecting an item from a combo box selenium driver
- Selenium in Java is not finding element when using
- How to send text to the search field through Selen
- What is the difference in “find_element_by_xpath”
- WebElement.getText() function and utf8
I couldn't have used this, as I have @ in my username (yeah, Microsoft account). That's why I decided to go for proxy solution that would intercept my requests and insert prepared Authorization header. And I wanted to use proxy directly in the test, so it is fully automated. Now the resulting code is rather rough, based on
Browser.drive
and not any state of art Geb code, but I believe that if you know Geb, you can easily adapt it:First it starts proxy - based on https://github.com/adamfisk/LittleProxy
Then it setups Firefox profile for proxy. Some of the setup is related to
localhost
usage but it will not hurt if you use any other hostname.Finally we start the test, providing the configuration into the
drive(...)
call.I yet have to get more experiences with the little proxy, how stable it is, etc. But for this easy case it works just fine. It is important to intercept only requests for
baseUrl
, because Firefox may call google search for instance - and you don't want to send your auth hash there (as it is easy to reverse). That's also why I provide it in the JVM argument:-DbaseUrl=http://localhost/finrisk -DbasicAuth=xxx...allTheWayToEqualSing=
Obviously, it is for Firefox now, but I guess it should be possible to adapt it for other browsers, if you can set up their proxy settings.
This is called basic auth. So you can pass username and password in the address bar
Basic auth is not supported by WebDriver
Try using this :
http://username:password@site.com/page
Instead of :
http://site.com/page