0

I asked before about providing login and password to a Windows internal login prompt screen from Chrome and Selenium. Someone referred me to Selenium - Basic Authentication via url. This solves my problem, but I have a (minor) problem still. My code portion looks like the following. The value of "href" is the href of the link on which I would click to open that requires a login and password via windows. (I substitued "login" for the login and "password" for the password because I do not want to list the actual values here).

JavascriptExecutor exe = (JavascriptExecutor) driver;
href = href.replace("//", "//login:password");
JavascriptExecutor exe = (JavascriptExecutor) driver;
exe.executeScript("arguments[0].setAttribute(arguments[1], arguments[2]);", itemEle, "href", href);
exe.executeScript("window.open('" + href + "')");

I open the window and close it again so that next time I click it will have the login and password remembered, and not prompt again.

The problem is, we have two frames, treeframe (left side) and baseframe (right side). You click a link in the "treeframe" frame, and it opens in the "baseframe". My solution works, but it opens the page in a new window (not frame) and then closes it, which is fine, but it might confuse the people running it, wondering why a window is open in a new window, instead of a frame, and close again.

I tried doing something like

 URL url = new URL(href);

but as the item says, regular Chrome opens won't use the login and password, so newing the "new URL" above did not work.

Is there something similar to this using javascriptexecutor where I can pass the login and password to the host without having to open and close a window, so it remembers the login and password still?

Tony
  • 1,073
  • 16
  • 28

0 Answers0