Selenium webdriver add_cookies working but can't log in - selenium-webdriver

Hello I'm using selenium and chrome driver to authomatically log in on amazon.jp and amazon.de.
I manually logged in on amazon.jp and checked the cookies
got cookies with get_cookies() and checked the list is okay
I opened the selenium driver and moved to amazon.jp and used add_cookies()
checked the cookies were added and it was same to what I got from "get_cookies()"
I moved to amazon.jp again and it seems that sign-in didn't work
The same process worked for taobao and other sites, so does Amazon uses some different ways(plus cookies) to log in?

Related

Start a browser with a logged proxy in Robot framework

i'm facing the current problem: Since i'm under VPN, when i open a browser, a browser popup appears and ask me for the user and password credentials:
I need to open a browser in robot framework (firefox or chrome is the same) with a logged proxy.
I know that is possible to open a firefox instance with a proxy by using SeleniumLibrary Create Webdriver:
${proxy}= Evaluate selenium.webdriver.Proxy() modules=selenium, selenium.webdriver
${proxy.http_proxy}= Set Variable localhost:8888
Create Webdriver Firefox proxy=${proxy}
The problem is that it seems not possible to pass the credentials (user and password) for the proxy login.
Also, like most of the people suggest, i know that is possible to open the browser logged in with the proxy by using the url formatted like (in past i've also used that on different projects):
https://proxy_user:proxy_password#url_to_reach.com
but for some reason it doesn't work, i still have the browser popup asking me the credentials.
I've also tried by using Input Text Into Alert but it doesn't fill the alert fields:
Input Text Into Alert text=username action=LEAVE
I've also thought that maybe it is possible to do by using some preferencies with chrome or a profile with firefox but i've found nothing about this. Any other method by javascript?
Anyone can help? Thanks a lot

Google API explorer redirects to https://apis-explorer.appspot.com/apis-explorer/#p/

Note:
I have googled, and read these issues:
Cannot access API explorer on localhost
How to force loading dynamic, insecure content in Chrome?
and many others but they do not solve my problem.
The problem:
I'm running MacOS and doing my development int Debian VM running in Paralells.
I start up the dev server using the following command:
dev_appserver.py --clear_datastore --host 0.0.0.0 --admin_host 0.0.0.0 app
and I can access the app, endpoints, admin module etc from MacOS using my Debian machine IP eg. http://10.211.55.6:8080/_ah/api/my-service/v1/api etc... everything works fine and as expected except for Google API Explorer.
When I try to access http://10.211.55.6:8080/_ah/api/explorer I am redirected to http://apis-explorer.appspot.com/apis-explorer/?base=http:///10.211.55.6:8080/_ah/api#p/ as expected and I get the ssl error as described in the issue above (again as expected) but then I get redirected a couple of more times and end up at https://apis-explorer.appspot.com/apis-explorer/#p/
Note: I cannot click on the lock icon in the title bar because of the redirects
I've tried almost everything I can think of and have google extensively to no avail. Hope someone can help me, I suspect it has something to do with the dev server being run inside of a VM, but I am not sure.
there is a shield icon in the rightmost part of the address bar that appears when you access the api_explorer locally in chrome. Click and then select load unsafe script and it will load all the service endpoints you define.loading api_explorer locally

WebDriver - "Keep Me Logged In"

I am testing an application that requires login. Using SafariDriver when I click the "Keep Me Logged In" button every new SafariDriver instance that is created is automatically logged in as expected; but when I use FirefoxDriver or ChromeDriver I am asked for my credentials every time as if I've never logged to the site using that browser before (when I have both manually and using webdriver). Is there some setting I need to enable so FireFox and Chrome keep me logged in?
This happens because WebDriver creates a new FireFox profile for every session. These profiles include caches/bookmarks/plugins etc. for more information refer to the documentation. FirefoxDirver allows you to start a FireFox with a specific profile. This can be done by using the following code:
FirefoxProfile ff = new FirefoxProfile(new File("/Path/to/profile/directory"));
driver = new FirefoxDriver(ff);
I'll update the answer if I find the way to do this in chrome

select file in Safari in Protractor

Executing this code in Safari doesn't work, but it works in chrome and firefox:
var pathToFile = path.resolve('./scripts', file);
element( by.css('input[ng-file-select="onFileSelect($files)"]')).sendKeys(pathToFile);
In digging around it looks like it's not possible to interact with file inputs in this way in Protractor running on Safari. Does anyone know of a workaround in Safari to put a file path in an input?
This is due to a leaky abstraction, which requires a Safari specific solution:
I guess the workaround for those that really want to do file upload for SafariDriver would be not to do it natively via SafariDriver but by using external code libraries to perform the upload via HTTP/HTTPS (POST) requests (combining any other form data in addition to the file being uploaded/sent), then get response and check whether upload succeeded or not, then go back to SafariDriver code and navigate to next page to check upload succeeded or not, and/or to continue from there for the next steps in the automation.
This approach would be similar to the file download method using HTTP requests externally that has been mentioned in various posts in WebDriver and Selenium user Google groups. Here, it's just the inverse, doing upload instead of download.
Though if the upload requires a session (cookie), then you can extract Selenium session cookie and use with HTTP request. Or if session is stored with session ID in URL, extract that and pass along with HTTP request.
References
Selenium Issue 4220: The SafariDriver does not support file uploads
How to upload file using Selenium when the file input is hidden?
Access is denied error in IE while file uploading
Changing the value of input file
Chrome file upload bug: on change event won't be executed twice with the same file
Selenium IDE 1.4.1 throwing security error when uploading a local file
Dynamically submitting a file upload form in IE10 using jQuery

Getting session not found errors in Selenium 2 for certain browsers

I'm sorry if this question is vague, but I have a set of Selenium WebDriver tests, and they are currently not working in Chrome or IE. For whatever reason Firefox works fine.
The error is very similar for both Chrome and IE, and it is perplexing because I know for sure that the Chrome tests have worked before.
(And yes, I do have chromedriver in the path and it is opening the browser).
Basically what happens is that the tests will run partway through and are even able to interact with the page.
Eventually, though, they all fail with this error:
org.openqa.selenium.WebDriverException:
session 2fca1234-343f-45e7-af49-6486b13e1eba does not exist
I was just wondering if anyone else has seen this error or anything similar.
I have looked around quite a bit and haven't found anyone having the same issue.
For the record, I am running my tests in Java and using Selenium 2.5
I've been seeing the Session not found error in my Chrome automation. By examining the logs from these failures, I've determined that the error occurs because the DELETE session command is sent twice at the end of the test. The first DELETE actually deletes the session, so the second DELETE has no session to talk to.
I haven't dug into the Selenium WebDriver code enough to figure out why DELETE session is sent twice.
I am using webdriver c# combination to automate my web based application, I normally get that error when I do webDriver.Navigate().GoToUrl(URL); and the URL string given doesn't opens any webpage
Try replacing driver.close() with driver.quit() for IE.
This helped me. I was getting a similar error when I was using driver.close() with IE while was working fine with both Chrome & FireFox.
When this happens it means that you have closed the old session of the web driver. Create a new instance of the webdriver.
Ie: for C#
var wdriver = new OpenQA.Selenium.IE.InternetExplorerDriver();

Resources