Selenium Webdriver Login activity on Amazon.com: “Verification needed” - selenium

I am trying to run some automated tests on amazon.com by using Selenium Webdriver. I tried to log in to the system but after entering the password, system either directs to “Verification needed” page and says “We will email you a code to verify your identity. This is required when something about your sign-in activity changes, like signing in from a new device or location.”
or directs to “wrong password or email” page (eventhough I try correct account information).
So my question is: How can I handle that two factor authentication in my test script?
Note: I am using ChromeDriver and Java

there are two possible approaches:
first one, you can as Kiril S mentioned, get the link from email (mailinator.com is fine inbox for such testing).
second approach is avoiding the second verification with existing browser profile. Selenium uses a temporary profile, that's probably the reason of the second verification. I'm using existing browser profile (firefox), see Selenium Chromedriver - Open Chrome Normally. For Chrome should be similar.

Related

Login through Google SSO using automated browser

I am trying to automate login to my app which uses among others, google sso authentication.
However login form return error "This browser or app may not be secure.". I set my google account options to allow less secure apps but still nothing.
I browsed few topics:
GMail is blocking login via Automation (Selenium)
Selenium Google Login Block
Automation Google login with python and selenium shows ""This browser or app may be not secure""
And it seems that google is blocking this way at all in favor of oauth.
People write in these topics that solutions stopped working recently
So is it currently possible, to set ChromeDriver somehow using capabalities, to be able to login through SSO?. I need a simple solution, that will run headless with other scripts on cloud (not something that would require me to manually login first on another instance as one anwser suggests).
If its not possible or extremly complicated please tell me I will not waste time on it.
If you want to use chrome capabilities, what you can do is set the user-data-dir to a chrome profile that has already been signed in using SSO.
You should look up how to reuse chrome profiles with selenium.
If your accounts have 2 steps verifications, google believe it's safer and allows you to get login. Then the issue will be how to handle the 2 steps verifications. Working on that :/

Can't login to gmail via Selenium Webdriver, asks for recovery email?

I am using Selenium Webdriver version 3.4 and chromedriver 2.35.528157. My test consists of entering a system through google, so when I click login through google it asks me to enter my email. When I enter my email and click next it asks for the screenshot attached, it does not get to enter password screen. I tried adding a recovery mail but if I follow the steps it just sends a verification code to the recovery email and complicates things all over. The weird part is if I do this manually in an incognito browser, Firefox driver or in headless mode on chrome everything works fine.
from selenium.webdriver.common.keys import Keys
variableForTextFieldId.send_keys(Keys.ENTER)
I was having the same issue as you when using either .click() or .submit(). However, I ended up using the Keys variable ENTER and it allowed me to get to the next part of login (The password screen).
You must be using the class for the xpath, which is same for 'Next' and 'Forgot email' links. Therefore it clicks Forgot Email and lands on the Email Recovery page.
There are 3 classes in the Next button itself. Try using the id of the first one.
Command:
driver.findElement(By.id("identifierNext")).click();
This will lead you to the Password page. Let me know it helped.

robot framework test user role single sign-on

I'm trying to use robot framework as a ui test tooling for a website we use internal.
To test different user roles I open the browser with basic authentication (http://user:ww#url). Unfortunately this methode is removed from chrome and chromedriver (http://www.chromestatus.com/feature/5669008342777856) (for the test I use PhantomJS).
because of this issue subresource requests are blocked. See image attached.
Because of this issue also js files are blocked and therefore my UI tests don't work properly.
Does anybody have an idee on how to solve this or another way of testing?
This issue is being encountered by all browser automation frameworks. This SO answer describes an approach to take a two step approach:
Go to the url with http://user:pass#hostname.ext
Go to the url with http://hostname.ext
The username and password are cached and subsequent visits will reuse it.

handle windows login pop-up using selenium web driver for https website

My scenario:
I am opening a https website, I get a login pop-up that is not identified by selenium webdriver. I have searched and found the below link which had similar question.
How to handle login pop up window using Selenium WebDriver?
I tried he solution given by #Pavel Janicek to pass the credentials via URL
It does not working for me, I mean after the browser is opened it keeps processing nothing happens after that.
In my case, it is a https site,i need to give username#domainname & password to login, giving only username will not work
my url looks like this
https://username#domainname:password#sitename.com
Has anyone faced this kind of problem?
Thanks
You can NOT auth with this window(in selenium without any additional framework as Robot). But you can auth without getting this window. Try change URL to: http://user:password#www.yourserveradress.com
if this will not help, you need to create separated profile in browser, pass authentication on this server and remember password and use this profile in selenium. Also I think its possible to use Windows active directory authentication, but cannot sure about details.

Diffrence between opening a browser/site through selenium and Manually

I have started learning selenium Webdriver API recently. I was trying to automate a simple task of launching gmail.com and logging into account using Chrome browser.
The difference I noticed is when I open browser manually it lists my accounts on the Home page and then I can select the account, enter the password and login in complete
When I launch gmail.com using selenium it directly gives me log in window when I can enter email and password
Any reason why we see the difference while launching browser through selenium