Does anyone know how I could get selenium to run an IE session utilising the \"Run as different user\" function using JAVA? I have no idea how I\'d even go about setting th
If worse comes to worst, you could just setup a file with your different usernames and passwords, read them in, determine the user you need through a factory class, and then select the user per test based on the parameters you need to look at. If you do it this way, when you are running on multi-threads, it will still pull in the correct user to login with.
I don't think this is your primary goal, but a secondary solution at minimum.
I don't know why you would want to do this, and I don't believe it is possible. However, I've made a few guesses at your end goal, with solutions for each.
If you want to start fresh (with no cache or anything), then simply start up a new IEDriver instance.
If you want to start it with different settings, you can pass in your desired capabilities.
If there is something else entirely you are trying to do, feel free to reply, and explain your situation.
Looks like it's possible to do this using Windows Credential Manager. I was able to manually set the username & password for the site, then drive there with Selenium and the alternate credential I specified was used to authenticate.
The next step is to set the credential at runtime, which should be possible with powershell.
Its quite possible i have done it may time. Easy way If you run selenium through eclipse. Just open eclipse IDE by right click open as different user.
The harder way create a Java>Runnable JAR file as mentioned in the article below.
https://www.joecolantonio.com/selenium-executable-java-test/
you should be admin on local machine to do it and should have windows account iusername and password for user:userA user:userA1 and so on. open multiple command prompt
C:\>runas /user:domainname\userA cmd
C:\>runas /user:domainname\userA1 cmd
C:\>runas /user:domainname\userA2 cmd
or
C:\>runas /user:domainname\username cmd
Enter the password for administrator: Attempting to start cmd as user "techblogger-pc\administrator" ... then type same jar file in command window Like c:\runnableselenium.jar and bomb you have all jar running with different credential Find a way to see the logged in user name on test page somehow.
Perhaps you can also setup the machines in your GRID with different users and reflect that in the environment Capability. Of course, it does require more machines in your GRID. I haven't tried this myself, though.
The only solution I got is to use robot class to open new session. Actually IE is not providing any shortcut to open new session so we have to do this by robots.
This code will open a new session for you. Best of luck
System.setProperty("webdriver.ie.driver","./IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com/");
try{
Robot robot=new Robot();
robot.keyPress(KeyEvent.VK_ALT);
Thread.sleep(3000);
robot.keyPress(KeyEvent.VK_F);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_F);
robot.keyPress(KeyEvent.VK_I);
robot.keyRelease(KeyEvent.VK_I);
}
catch(Exception ex){
System.out.println(ex.getMessage());
}