Automating login with Selenium
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2014 08:13 PM
Hello,
I'm playing around with Selenium and I would like to automate the login for my "Hello World". If anybody has experience with automating ServiceNow testing with the FirefoxDriver, how do we deal with finding the elements in the the iFrame?
Thanks,
Trey Carroll
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2014 07:12 PM
I am interesting to know about it too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2014 08:33 AM
Hi Jesus,
Here is what I have so far for the login piece:
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://mycompany.service-now.com/navpage.do");
driver.SwitchTo().Frame("gsft_main");
FirefoxWebElement e = driver.FindElement(By.Id("user_name")) as FirefoxWebElement;
e.SendKeys("myusername");
FirefoxWebElement e2 = driver.FindElementsById("user_password").First() as FirefoxWebElement;
e2.SendKeys("password");
FirefoxWebElement loginButton = driver.FindElementsById("sysverb_login").First() as FirefoxWebElement;
loginButton.Click();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2014 10:26 AM
With this you are able to log in to the instance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2014 02:43 PM
Hi Jesus,
Yes. This code opens up Firefox and logs into ServiceNow. The missing step would be to add an assert that confirms that some element on the page that is only visible to someone who is logged in is present on the page.
Regards,
Trey Carroll