Use Currently Saved Cookies in Watir Webdriver - ruby

Is it possible to use currently saved cookies in Watir Webdriver when launching Chrome?
I set my chrome to "remember me" when login to facebook so that the next time I access facebook, I don't have to type the username and password again.
But, when using watir webdriver, the Chrome will open it like new session and accessing facebook like the first time which requires me to type the username and password again. I expected it to directly open facebook without going through the login page again.
Is there a way to do that?
Thank you very much.

You need to create a custom profile for Chrome, adjust its settings as desired, then direct Watir to use it by setting the Chrome switches.
args = ['--user-data-dir=/path/to/your/custom/profile']
Watir::Browser.new :chrome, options: {args: args}

Related

Passport cookies not working on Incognito mode

I can't find any clue about this problem, what make me wonder if I am wrong from basic knowledge.
I am building an application with mongo, nodejs (with passport), and react.
Users can log in into this application correctly in normal windows browsers.
Session cookie is set with passport, and the flow is working.
Problem starts, when I tried to log in through Incognito Mode from google chrome (or any other browser).
Is any problem about cookie session in Incognito Mode?
Should I use other method to go over this case?
I think it is not relevant any code of how I set cookie session, but if someone need it I will paste it.

How to open a url on browser using expect script?

My bash script when runs produce a URL (basically a login URL to azure), wherein the user has to login to Azure account. I want to automate this using expect script so that the URL automatically opens up in the browser.
This is the kind of URL that my shell script produces :
Please log into Microsoft Azure
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ******* to authenticate.
Depending on JS usage on the webpage, you will not be able to login using expect / curl.
You might want to consider using selenium with firefox, which can record a standard login session and replay it later.
You might then fun firefox headless with selenium to login.

Capybara: HTTP Auth. after redirect

I'm facing a problem with HTTP Auth after redirecting from another page.
So let's assume. In my test i will visit my url with e.g visit('http://admin:password#url1').
After doing some stuff on this site i click on a button and i will be redirected to another site (http://url2.com) which requires a http auth as well. Now I need to enter new credentials which are not the same as from url1. Selecting the element and filling it with input will not work. I'm using Ruby with capybara and firefox with selenium-webdriver. How can I do this?
Since you're using selenium-webdriver, after clicking on the button you can try
page.driver.send(:find_modal).authenticate(username, password)

Add Cookie keyword does not set the cookie as expected

I am running a robot test using the Add Cookie keyword. In Firefox if I click View Page Info -> Security -> Cookies the cookie value is set. However if I type in the console: document.cookie.split('; ') I don't see my cookie in the list.
Could anyone explain why that happens?
I am using Firefox 23.0.
This is a side-effect of using private browsing. The default profile used by Selenium2Library has private browsing enabled. Use the ff_profile_dir argument to Open Browser to point to a Firefox profile that does not have private browsing enabled.
From what I gather, it is a bug/quirk in Firefox. Both the Cookies dialog you mention and Selenium seem point to a cookie manager that is disconnected from the browser and the browser is using a different cookie manager to support private browsing.
See https://github.com/rtomac/robotframework-selenium2library/issues/177

Can we handle OS pop-up using "gem sikuli" in selenium script

When I hit url in browser it gives windows authentication pop-up and we need to enter proper username and password into that then only it will give home page of that site.
It is not able to handle windows pop-up using Selenium-WebDriver
I was trying to handle that pop-up using gem sikuli code inside selenium script but it is giving error as
Timeout::Error: execution expired
OS pop ups cannot be handled using Selenium Web Driver , however there are numerous other frameworks that can handle it. This is for a upload window , thus should work for your scenario too.
This is what I use in C#
driver.get("http://LOGIN:PASSWORD#localhost:8080/myApp/")
LOGIN> -> username which you need pass for authentication
PASSWORD> -> password which you need pass for authentication
After # put your URL.
Don't forget to put / at the end of the URL, At-least for firefox.

Resources