2

If I am already logged in to my gmail or facebook account and write an automation script from there onwards(e.g. url for inbox) why does it go to sign-in page at run time?

And how did the developers make this possible?

[Edit]

Steps:

  1. Login to my gmail account manually
  2. Get the URL of the already logged in page and include it in the automation script

    driver.get("https://mail.google.com/mail/u/0/#inbox");
    
  3. Run the script

Result: Goes to the sign-in page instead of the specified URL

  • Can you provide a complete code to reproduce the issue? – dzieciou Mar 19 '16 at 13:44
  • I think you are trying to re-use your manual browser sessions, but just to be sure. Do you have code to login to gmail/facebook? and do you execute this before you get the sign-in page? – Niels van Reijmersdal Mar 21 '16 at 8:04
  • @dzieciou Added more description. My intention was to navigate into an already logged-in session instead having to log-in each time at run time. – ilm Mar 29 '16 at 10:56
1

Your script is using a different browser session. Have the script log in using your username and password on the log in page.

If you have a pre-existing account then navigate to a log in page, input the username and password, then click the login button. If you always explicitly log in, then you do not have to worry about your credentials expiring or something.

  • Little more description would really be a great help! – IAmMilinPatel Mar 21 '16 at 1:24
1

Selenium / Webdriver creates a new session/profile and starts a new clean browser for each test run. This means each Selenium session runs in a clean browser and any logins on other browsers windows are not re-used or valid. The reason for this is to test in isolation and prevent unexpected behavior of cookies, etcs.

What you are trying to-do is also a bit of a bad practise, since your tests now become depended on a manual step, namely loggin into facebook/gmail.

According to this answer on SO it is possible to use a RemoteWebDriver and hijack and existing browser sessions.

System.Uri uri = new System.Uri("http://localhost:7055/hub");
WebDriver = new RemoteWebDriver(uri, DesiredCapabilities.Firefox());

Also have a look at this blog: http://www.binaryclips.com/2016/03/selenium-web-driver-in-c-how-to.html

0

When you try to open a URL through script, script triggers the browser instance, it doesn't know that you've already signed up until explicitly mentioned. So,it lands on the login page.

  • So how can this be resolved? This is the problem you've identified, any solution for it? – IAmMilinPatel Feb 18 '16 at 10:07
  • 2
    write a code to sign up in the browser instance..easy. – Tester_4fun Feb 18 '16 at 10:35
0

I suppose what you are asking is this Accessing Same Session in A New Window. I suppose you can achieve this using cookies. Although I am not sure this is correct, because I haven't done it myself.

Not the answer you're looking for? Browse other questions tagged or ask your own question.