Run chrome as different user using Selenium and C# - selenium

As part of a testing project, I am trying to run a chrome instance as different user ('UserA') using Selenium and C#. I have tried all suggestions I could find, but nothing works. No matter what I do, the Chrome instance that is opened during the test, runs as the user logged into the machine and not as 'UserA'. Everything runs locally.
I am fairly new to this, so any advice/suggestion is appreciated

Related

Trouble getting Selenum automated testing to auto-login using my profile

I'm using MS Edge browser (Version 109.0.1518.78) along with Selenium to do some automated UI testing with my corp environment.
Trouble is, the tests are always prompting challenging me to login.
Now here's the confusion: when i use Edge normally, the browser uses my profile settings to auto-authenticate me. However, when running the tests (via Visual Studio), an Edge browser instance is started WITHOUT my profile.
First thing I tried:
I have tried following various example without any success, such as this one from SO. Using this example i added these 2 arguments like this:
This didn't do anything. So I'm wondering if maybe the arguments have changed? The edge driver documentation is worthless when it comes to this.
Second thing I tried:
I tried creating edge driver service with arguments of my edge driver path.
Unfortunately, i get a driver initialization error saying something about "msedge.exe".
Summary
The summarize, my problem is that my selenium tests are starting an edge browser instance without my default corp profile. therefore i am forced to manually login, which is what i want to avoid.
Note that occassionally things will work fine as expected. Then suddenly the next day it reverts to this default behavior again. I am no sure what is going on!

Serenity how to keep browser only one instance through the test

I'm using Serenity jbehave to automate my webapp, and I got trouble in keeping one browser instance through the test.
My app need to login to perform any test, so I don't want to start new browser and login again and again every story.
I tried the setting below but it seem not work as expected. I am using Serenity 1.5.rc-1 with latest Firefox and Chrome, my test always open new browser every story run, if I run 5 stores, then there are 5 instance of Firefox open.
I googled for 2 weeks, but I'm still stuck.
Please help!
serenity.properties
serenity.use.unique.browser=true
serenity.restart.browser.for.each=NEVER
restart.browser.each.scenario=false
JBehave doesn't support using a single browser across all stories (there is no way of knowing when the suite has finished running, so no way of knowing when to shut down the browser cleanly), so the optimal setting is
serenity.restart.browser.for.each = story
This is actually a good compromise, as some WebDriver instances can become flaky when run for too long with the same browser.

Selenium Golang binding without server

There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.
How can I control browser with Golang and selenium without selenium server?
You can try github.com/fedesog/webdriver which says in its documentation:
This is a pure go library and doesn't require a running Selenium driver.
I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.
The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.
I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.

Run Selenium tests in one browser while using a second browser window

I am running Selenium automation test in one browser, but at the same time, I want to open the browser in another window and do something like checking mail, googling email then active mode or focus is coming to the current working window, not the automation test run browser.
Is it possible to work on the browser while automation test is run?
In general, when doing UI automation, you cannot use the test machine to do any other tasks that involve using the keyboard or mouse.
Since WebDriver automation performs keyboard and mouse input, such as typing text and clicking items, you will be constantly interfering by taking focus away from the WebDriver instance of the browser and doing your own mouse and keyboard interaction in other applications.
This will adversely affect both you and the automation, with neither being able to do what they want to do!
You should either use a separate test machine, or setup a virtual machine using software such as VirtualBox (free).
Did you try doing that?
Selenium uses WebDriver to communicate with a specific instance of a browser, not the currently focused window. So you should be able do continue to use other instances of browser windows. The best thing to do would be try.
If it isn't working, I would recommend getting a VM up and running and using that as your test environment. Generally that is the way I work to keep everything separate.
I ran my tests on Firefox and then used chrome on the side. Otherwise, run your tests on a remote machine.
You can do 2 things
1. Use a third tool to run test cases like Jenkins. so that test will run in memory.
2. If you are using firefox you can create a seperate firefox profile so that if you use firefox at the same time there should be any issue.
To Create new FF profile use below code:
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(false);
profile.setAssumeUntrustedCertificateIssuer(true);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(dc);

How to configure Selenium for IE9 when using HTTPS

I'm trying to get Selenium tests to work through PHPUnit. My tests pass in Firefox, but not in IE9. In IE, no matter what combination of settings I've tried, when the Selenium server is running IE will not go directly to the page, and instead displays "There is a problem with this website's security certificate".
If I shut down Selenium, I can use IE to access the site being tested with no problems.
I've tried telling IE that the CyberVillians cert is OK, I've added the cert to IE's list of certs, and tried various Selenium Server command line options.
For what it's worth, I'm using the very latest Selenium and PHPUnit files (downloaded today).
Any ideas?
The solution was indeed to abandon using Selenium RC.
I ended up using chibimagic's Webdriver for PHP, and everything works great. I'll probably end up writing a brokering class to make in interface more like that of PHPUnit_Extensions_SeleniumTestCase. That way, I can work up test scripts using Selenium IDE, using their PHP formatter, and then just paste into my unit test.