Im trying to create test cases with Serenity BDD (using selenium).
I have accepted the fact that between each test case it "restarts" the browser.
And I found a way to not do between Scenarios.
But what Im looking for is to run the test in normal browser mode and not in incognito.
I want the browser to click the "remember me" option, log in, log out, and see username and password in the fields.
But since the tests are running in the browser with incognito mode, the password is blank.
Any suggestions ?
Thank you
You can configure your driver to run on specific profile of browser.
Below is the Mozilla link with steps to configure your profile:
https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data
Once you have configured that profile you can launch that browser manually and save all the user name and passwords manually.
So next time when you launch this profile of browser user name and password fields will be auto filled.
*ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile();
WebDriver driver = new FirefoxDriver(myprofile);*
Related
There is one case that, when i open the URL manually in chrome browser and give the credentials.
After clicking on sign in button one OTP will come to mobile. There is one checkbox after entering the OTP. Don't ask OTP for this browser. If we click on that check box and login into the portal. Then from next time if we open same browser and access the portal, it will not ask for OTP. So can we automatically open same browser every time after closing browser. Without calling new chrome instance.
You can use the default profile to use the local chrome profile once the OTP is completed manually.
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
ChromeDriver driver = new ChromeDriver(options);
You can get the default profile path as shown in the below screenshot.
Please open chrome://version in the browser to see what profile Chrome is using.
In my Selenium Tests I need to test a webpage where I use a basic Authen,
Knowing that I am using Chrome Headless Java and Selenium WebDriver.
On my machine 'locally' It works perfectly using driver.get("https://admin:admin#localhost..");
and then
driver.get("https://localhost..") for example.
I know that Chrome doesn't support this function anymore but I managed to make it work based on someone's solution here by passing the first URL with credentials and the second without.
But when I run it on remote (Jenkins) On Linux servers I get the following Error
the configuration of your browser does not accept cookies
. I don't have vision on the servers when I can configure Chrome ..any ideas how to make it work without facing that problem.
I know a lot of people asked that question before, But I didn't find any valide answer for my issue.
try ChromeDriver 2.45 (changelog) or change the location, where it is supposed to save the cookies:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
otherwise (per default) it would create a new temporary directory each time it starts a session.
ChromeOptions options = new ChromeOptions();
//Command line flag for enabling account consistency. The default mode is disabled.
options.addArguments("--account-consistency");
//Chrome that will start logging to a file from startup
options.addArguments("--log-net-log=C:/some_path/resource/log.json");
//Sets the granularity of events to capture in the network log.
options.addArguments("--net-log-capture-mode=IncludeCookiesAndCredentials");
Try this, basically, it saves the logs on startup of chrome browser, then it will set the account consistency. Anywhere from the log, you can debug the issue.
Hello I managed to fix the problem (I forgot to mention that our website is protected by Siteminder) so I did the following following:
1-We inject the USER and the PASSWORD on the URL :
The issue we faced was that the displayed prompt wasn’t part of the page’s HTML and it was hard for us to catch it using Selenium. We managed this by directly injecting the user login and the user password in the URL as follow :
‘https://USERNAME:PASSWORD#basicAuthentURL’
This will launch the Chrome session. Beware, this is only the first step of the process. The user identification have not been performed yet.
2- We create a new cookie :
After launching the URL, we have to manually create a cookie called « SMCHALLENGE » and add it to current session with Selenium, for example in JAVA :
new Cookie("SMCHALLENGE", "YES");
3- Call the URL without the user credencials :
As the SMCHALLENGE cookie is now set, the last step is to call the URL again (https://basicAuthentURL ). The SMCHALLENGE cookie will be deleted once the authentication succeed and a SMSESSION cookie will be generated by Siteminder.
The SMSESSION cookie now allows us to call the application and sucessfully pass Siteminder as if normally logged in (via SSO).
Let me know if you try this out.
I've created a Maven project with 20 tests made with Selenium Webdriver (java). Now, when I want to execute my Maven project, I get sometimes the following error:
Mozilla error
This is due to login every test. So, when I want to run 20 tests, sometimes that error appears and I can't continue my test, so it returns "Failed test" in Selenium Webdriver.
Does anybody know how to fix this problem?
I've tried to put "Thread.sleep(30000);" at the end of every test to give them some time "not to seem a robot", but it doesn't work...
Thanks so much for your help guys!
Here is the Answer to your Question:
The Real Issue:
The URL/Connection with which you are a working if it is Not Secure then whenever you access the URL through Mozilla Firefox 53.0, Firefox will display a lock icon with red strike-through red strikethrough icon in the address bar. Now when URL gets loaded the cursor by default will be positioned on Username field and there will be popup showing a message This connection is not secure. Logins entered here could be compromised. Learn More like this:
Now your script through Selenium enters the username within the Username input field and the Not Secure popup overlays the Password input field.
Next if you try to call the click() or sendKeys() operation in the Password input field the Not Secure popup receives the click and Insecure password warning in Firefox page opens up in the next tab along with Selenium shifting its focus to new tab. Hence test-case starts Failing.
Solution:
In these cases the best solution is:
Create a new Mozilla Firefox Profile. You will find the documentation here. For Example, I have created a Firefox Profile by the name debanjan
Configure the Firefox Profile debanjan to ignore all the UntrustedCertificate issues.
Rerun your Test Script without any issues.
Here is a sample code block to disable insecure_field_warning:
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
ProfilesIni profile = new ProfilesIni();
FirefoxProfile testprofile = profile.getProfile("debanjan");
testprofile.setAcceptUntrustedCertificates(true);
testprofile.setAssumeUntrustedCertificateIssuer(true);
testprofile.setPreference("security.insecure_field_warning.contextual.enabled", false);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, testprofile);
dc.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(dc);
driver.manage().window().maximize();
driver.navigate().to("http://demosite.center/wordpress/wp-login.php");
Let me know if this Answers your Question.
Is it possible to add passwords to a profile that's created as an instance of org.openqa.selenium.firefox.FirefoxProfile?
From Mozilla docs (Profiles — Where Firefox stores your bookmarks, passwords and other user data), I can see that Firefox stores passwords in two files:
Passwords: Your passwords are stored in the key3.db and logins.json files. For more information, see Password Manager - Remember, delete, change and import saved passwords in Firefox.
But can't see any way in the FirefoxProfile class to either add passwords to a profile individually, or to pass in files like logins.json/key3.db. (I can't find anything on the linked Mozilla pages either, which seem to be storing passwords as a regular user, rather than programmatically)
In my Selenium test suite, I'm creating a Firefox profile on the fly in code but am having to encode passwords (e.g. for HTTP Basic Auth on Dev servers) into URLs like this:
http://user:pass#localhost/example.html
(I know I could create an entire profile and add that to Git, to be passed around, but would like to avoid that if I can)
I read through the selenium firefoxprofile code for v53.0 and didn't see anything obvious. However, you could copy those two files from the existing profile into the default profile created by selenium. You only need the location of the newly generated default firefoxprofile which you can get (dynamically) when executing:
FirefoxProfile profile = new FirefoxProfile();
System.out.println(">> path to profile=" + profile.layoutOnDisk().getAbsolutePath());
// Copy the two files
WebDriver driver = new FirefoxDriver(profile);
Yes it is possible to create in firefox profile
Click the menu button and then click ExitQuit . Note: You can use -P , -p or -ProfileManager (any of them should work). Press Return. The Firefox Profile Manager (Choose User Profile) window should open.
I was automating an angularjs application using selenium webdriver. I am using IEDriver 32 bit version to driver the IE execution. Typically, the scenario is admin user will register a user, this user will click on the registration link mailed to their maid id. Then it will input some required information, automatically it will be navigated to login page where user have to input the username and password and login.
But application warns to enable cookies at this point of time. If we are renavigating to the login page there is no issue.
This issue is not reproducible everytime.
Is there any way to enable cookies while setting up the IE profile?
There are many ways as you can find cookies in the below path
In Windows 8 for IE10, cookies are saved in the hidden protected OS folders below:
C:\Users(user name)\AppData\Roaming\Microsoft\Windows\Cookies
you can open IE and then navigate to internet options/privacy/advanced privacy settings.
There you can accept and block cookies.