The AUT contains the login page which validates the user credentials. Once successful, the user needs to hit a new URL in a new tab to access the actual application.
Is it possible to automate the above scenario using selenium RC?
Yes it's possible, but I'd recommend using Selenium WebDriver as it's the current version. Selenium RC is very old.
Using Selenium WebDriver:
driver.navigate().to("http://aut/login");
driver.... // login logic like setting the user/pass clicking login.
...
driver.navigate().to("http://somenewurl.com");
// continue testing here...
If you are adamant on remaining with Selenium 1 (which i could understand if you already have a big suite in it..):
selenium.open("http://aut/login");
selenium... // login logic here
...
selenium.open("http://somenewurl.com");
// continue testing here.
Related
I am running testcafe tests on an authentication page and I can see that testcafe is modifying/removing/adding the headers when sending the requests to the website and this is blocking me to do 2FA on this page
As soon as I got the issue, I tried to do the automation with Selenium just to confirm it is testcafe issue. As selenium doesn't create a proxy to insert the js scripts and automate the website I could do the automation with selenium, but I want to use testcafe as the site is developed in react.
await t.typeText(this.emailInput, config.userEmail)
.click(this.nextButton)
.typeText(this.passwordInput, config.userPassword)
.click(this.nextButton)
.click(this.otpOption)
.typeText(this.otpInput, this.token)
.click(this.signinButton)
}
When clicking on the next button I should have the 2FA form asking for the code, but I got a page saying was not possible to do the authentication (Something wrong happened) and I saw the response code for the BeginAuth endpoint was 222 without any response instead of 200.
The URL is that I am using to authenticate looks like this one:
https://login.microsoftonline.com/client uuid/oauth2/authorize?response_type=code%20id_token&response_mode=form_post&client_id=client uuid&scope=openid&x-client-Ver=4.0.0
Testcafe team found out this is a bug on testcafe-hammerhead, they have fixed and it is going to be included in the next release.
https://github.com/DevExpress/testcafe-hammerhead/issues/2052
For now I am generating the cookie in the automation and sending it in the header.
Normaly you are using selenium to automate testcases and after the testcase finished running, the browser closes.
However I try to use selenium webdriver to script specific tasks, e.g. login to a specific page but the browser should stay open after it.
I need the browser to stay open, because I developed a CMS where you can define selenium tasks and execute them. One of the tasks is to login to a backend, but I need to keep the website open forever, so that I can work in the backend. Problem: after about 20 minutes or so the browser which opened by starting the testcase, closes again.
I developed the portal so that I don't have to login to all my backends if I start working at the morning, I only have to login once into my portal and from there I can trigger everything I need.
I do it like this to login to typo3 backend (snippet):
$username_field = $SeleniumObj->byId('t3-username', true);
$pw_field = $SeleniumObj->byId('t3-password', true);
$submitButton = $SeleniumObj->byId('t3-login-submit', true);
$username_field->sendKeys("myusername");
$pw_field->sendKeys("mypasswd");
$submitButton->click();
exit;
You can see that I call exit at the end so that the "testcase" ends and the page stays open.
How to set the browser lifetime to infinite?
NOTES: I am using the latest selenium and facebook php-webdriver with custom code wrappers.
Testcase is to login to specific page.So, after using login credentials once login to specific page successfully, then testcase ends there.
Remove exit & see.
I have a suite of three test cases to be run in selenium webdriver.
First and third test case requires a login whereas the second does not.
When I run the suite,it asks for the username and password,performs the first test case and then second test case runs in which the login is not required.It is actually a pre login test.After this when the third login starts it doesnt ask me to login again(the second test case should have ideally logged it out)..it instead takes the login credentials I provided in the start.
How is this happening?
if you have not logged out and the session has not timed out, there should be no reason for your application to ask for login credentials. You should ideally be logging out after each test so all tests are independent of each other.
you can use the below link to achieve this
Maintain and re-use existing webdriver browser instance - java
Or if you are using TestNG you can use ITestContext where you put the driver in context which you can use in 3rd test case so that you will get the session.
Good day to all.
I'm use Selenium WebDriver to automatically test execute. But on development site using HTTP base autentification. I found AutoAuth addon for Firefox. It save login/password and don't need type credentional each time.
But this plugin don't save credentions. I'm reinstall addon and firefox, delete cookie, but nothing. On this machine in other user plugin work successfylly. Maybe, anybody have and resolve this problem?
To author of addon I wrote already.
Way:https://login:passwd#host don't help too...
Do you mean plugin not working on invoking with webdriver? simple way to create profile and call that provide in webdriver.
Here is the way to create firefox profile. Install that add-in and save credentials.
Call above saved profile in webdriver
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("selenium");
WebDriver driver = FirefoxDriver(profile);
Thank You,
Murali
If it's a HTTP Basic Authentication, then you can set the credentials in the URL. Note that it requires to set the "network.http.phishy-userpass-length" preference to enable it.
Here is a working example with Selenium / Firefox / Python:
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("network.http.phishy-userpass-length", 255)
driver = webdriver.Firefox(profile)
driver.get("http://admin:admin#the-internet.herokuapp.com/basic_auth")
The approach I've used very successfully is to set up an embedded Browsermob proxy server (in Java code) and register a RequestInterceptor to intercept all incoming requests (that match the host / URL pattern in question).
When you have a request that would otherwise need Basic auth, add an Authorization HTTP header with the credentials required ('Basic ' + the Base64-encoded 'user:pass' string. So for 'foo:bar' you'd set the value Basic Zm9vOmJhcg==)
Start the server, set it as a web proxy for Selenium traffic, and when a request is made that requires authentication, the proxy will add the header, the browser will see it, verify the credentials, and not need to pop up the dialog.
You won't need to deal with the dialog at all.
Other benefits:
It's a pure HTTP solution, it works the same across all browsers and operating systems.
No need for any hard-to-automate add-ons and plugins, any manual intervention.
No need for custom profiles, custom preferences etc.
You control credentials in your test code, and don't store them elsewhere.
Currently I am working on some Automation testing on Salesforce using Selenium webdriver.Salesforce system asks for a two step verification code(mobile/email OTP) apart from the usual credentials.Now, once you verify the user with the OTP, the application supposedly saves it in the cookies. So, from next instances only user id-pwd combination is sufficient to logon.
So, for that I have created a custom profile in firefox and tried to launch it through my code.But each time I am running it, a new temp profile is getting created where the cookie details are not saved already.
This is the snippet of the code:
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("SFDC");
WebDriver driver = new FirefoxDriver(profile);
When I am trying to log in manually this(2 step verification) is not happening.The automated execution was working properly before 27th Jan.
Can you please help?
You might want to look at this post in the Salesforce Stack Exchange: https://salesforce.stackexchange.com/questions/107027/selenium-testing-two-factor-authentication-problems/107368
There they have a solution where you can disable the 2-factor authentication by white-listing your IP in Salesforce. It worked for me.