how to disable the message this connection is not secure the logins entered here could be compromised in selenium webdriver - selenium

I am testing a login functionality in firefox with selenium in which when I get to the password field, it shows the warning as "this connection is not secure the logins entered here could be compromised" overlapping the login button, because of which instead of login button this warning receives a click. Can anyone suggest any solution for this?

That's a firefox setting. You'll want to
1) open firefox with the profile used by Selenium.
2) Go to about:config (in the address bar)
3) In your settings search for this: security.insecure_field_warning.contextual.enabled
4) Put that setting to false.
5) Close Firefox and run your test

I understand that some other toaster message is covering the button and so webdriver is not able to click it. We can do the following things to overcome this scenario.
Wait until the toaster disappears(in most of the cases the message will disappear in few seconds.
Try clicking somewhere in the screen so that the toaster vanishes and the button becomes visible.
In some cases, if we hit enter after populating the credentials it will probably log in. After entering the credentials sendkeys "Enter".
Hope this helps you. Thanks.

Related

getWindowHandles not working properly with latest edge browser version

I am working on an application which supports only Edge Browser.
The login functionality works as follows -
On the login screen, when username and password values are provided and login button is clicked, a new browser window opens with an active alert pop-up saying Login Successful along with OK button similar to the image below -
Also, when this new window opens, the old browser window goes blank.
When user clicks on this OK button (or hits ENTER button on keyboard), user home page loads on this new browser window itself and the old window remains black throughout the session.
Automation -
To handle this flow in automation, I have used getWindowHandles() method where I get the handle of this newly opened window and accept the alert.
This used to work properly till edge browser version 105.
However, when the edge browser version was upgraded to 107, I started facing the issue where the getWindowHandles() method goes into infinite loop and eventually the test times out.
I also tried to simulate ENTER button hit by using Robot class but it made no difference.
I have tried using the edge-driver version matching with the current browser version 107 but the issue persists.
Can someone please let me know what can be done for this? Is these any known issue with newer edge browser version?
Thanks in advance..!!
This is the code written to handle multiple windows and the test times out at getWindowHandles() method itself.
for(String wh : driver.getWindowHandles()){
driver.switchTo().window(wh);
}
Adding a Wait may be the key to this problem:
WebDriverWait wait = new WebDriverWait(driver,20);
BTW, I've tested in Edge 108 (also with Edge Driver 108). There's no such error message and everything works great. You can upgrade to 108 and see whether this issue has been fixed.

Robot Framework too fast for New Window

I'm exploring Robot Framework for some smoke testing of a site, and at a point have to sign in, which opens a new window. Moving to the new window with Select Window works for me, but I'm bridging this change by identifying the title of Sign In, and the new window does not immediately adopt that title as it loads your login form - sometimes this takes half a second, sometimes more than 5.
I'm working around this right now by having the test sleep for the obnoxiously long period of 10s, but surely there are more reliable ways of ensuring that I can change my target window to the new one, and not have my test fail and exit while the page is loading. I took a shot at using the redirect url as the identifier, but sometimes it redirects very quickly and fails, or if not, then it gets hung up on the next check for the login field that isn't loaded. I've seen commands like Wait Until Element Is Visible, but unfortunately that doesn't help when I can't target the window where things are loading...
For the sake of it:
*** Test Cases ***
Basic Workflow
Open Browser To Homepage
Go To Sign In
*** Keywords ***
Open Browser To Homepage
Open Browser ${HOMEPAGE} ${BROWSER}
Maximize Browser Window
Set Selenium Speed ${DELAY}
Go To Sign In
Click Button Sign In
Sleep 10s
Select Window Sign In
Title Should Be Sign In
Using Selenium2Library currently.
lauda had it right in writing out a Keyword for managing the Select Window. I found Wait Until Keyword Succeeds and made a keyword for it to wait on.
Go To Sign In
Click Button Sign In
Wait Until Keyword Succeeds 20s 3s Switch To Sign In Page
Title Should Be Sign In
Switch to Sign In Page
Select Window Sign In
Thank you, both!

Have selenium interact with safari "store password" popup?

I have a selenium test that tests the login of a site through a browser instance available on a selenium-grid. This works fine when using a firefox browser instance but when using safari the test cannot get through the entire test because safari pops up a window with the question "Would you like me to save this password".
It doesn't seem to appear as a window_handle nor as an alert. How can I have selenium dismiss this safari popup and continue its test?
You can't. WebDriver cannot interact with browser and/or OS specific dialogs.
You probably have two choices:
Save/dismiss the password manually the first time you run through the test, then reuse the profile every time.
Press Enter or Esc programatically via your programming language. You didn't specify which one you're using, so here's a Java example:
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
It's a hack, but it's reliable and it's what I've been doing to overcome similar issues.
Try this code, it uses JavaScript to change the password to text, and this stops the pop-up:
driver.executeScript("Array.prototype.slice.call(document.getElementsByTagName('input')).forEach(function(e){e.type=e.type=='password'?'text':e.type;});");
Alternatively, you can selectively disable password capture for specific domains. You can also disable password capture altogether by clearing the auto-fill option for username/password.

Error in Selenium testcases while running

Using Selenium IDE, I recorded one testcase that contained a click url, then give the username and password and clicked the button to navigate to next page.
In the render page, if I click any link the error is shown as Element link=linkname not found.
Why does this error occur?
Page is fully loaded when that command is executing?
If not just put waitForPageToLoad or pause command.
waitForPageToLoad | timeout
Or
pause | 5000
Also you can use command clickAndWait for button after entering username and password
There are different ways via which you can handle such issues. The issues can be of rendering as username and password click is fine as you will rest on same page when you enter values in these test boxes.
But as soon as you click on submit button then application has to load a new page with the credentials you have just added.
So this requires some time in terms selenium. What you can do is you can put some waits just after this action. So far selenium provides two types of waits Explicit and Implicit waits.
And you can try thread.sleep() , its a java type of method which is also a kind of wait. But implicit and explicit waits are highly recommended in Selenium coding.
You can refer to this blog for more knowledge on waits (http://khyatisehgal.wordpress.com/2013/05/09/how-to-handle-timeouts-implicit-and-explicit-waits-in-selenium/)
Khyati Sehgal

Selenium Web Driver - login event not launching

I'm using Selenium Web driver for testing, but can't ecen get past login page. The code I'm using:
driver.Navigate().GoToUrl(baseURL + "URL");
driver.FindElement(By.Id("loginForm:username")).SendKeys("uName");
driver.FindElement(By.Id("loginForm:password")).SendKeys("pass");
driver.FindElement(By.Id("loginForm:login")).Click();
Element locators are correct and login click is happening, but after that I am not logged in, but page is just stuck there - no error or something. Same code worked in IDE.
I'm using IE9 and also there is changed settings:
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
driver = new InternetExplorerDriver(options);
Any advices how to overcome this problem?
This happens with me very often, but not sure if it is the same reason for you.
When you run the tests locally, all the actions (sendkeys, click etc) take place really quickly. The loginForm:login button could be kept disabled until the user enters text in fields loginForm:username and loginForm:password. So there is a possibility that the button loginForm:login could have not been active when it is being clicked.
So I would recommend using an explicit wait to check if the element id loginForm:login is displayed before clicking it.
This step is basically useless but all it does is simply waste some time between "sending keys" to the password text box field and clicking submit.
Also for a quick check you could also do something similar to sleep 2 (make the script sleep for 2 seconds) after entering the password and before clicking the login button.
IF you eventually plan to run this on a remote machine, you dont need to do any of the above two steps, the time delay due to communication between the machines will be sufficient for the whole process to work smoothly.
(The same problem occurs on the linkedin login page- Login button is disabled unless Username and password is entered, but the speed at which the webdriver performs each step, The login button is not active when being clicked on.)