0
votes

I'm trying to write a script to access a Cisco Wireless LAN controller. I'm using Selenium and Chrome, and I'm stuck on the login page. From what I can tell, clicking the 'login' button on the Cisco splash screen triggers a javascript called loginAction() to prompt the user for a username and password.

The problem I'm getting is that the popup login box has no identifiable elements. When the login box is displayed, the cursor is already active in the username field. It seems that I would be able to use the sendKeys function to simply enter a username in the currently active text box, but it doesn't work. Since I don't know the id of the text boxes, I can't use something like driver.findElement(By.id("authlogin")).sendKeys("username");

Looking at other forum posts, I've seen where a common solution is to embed the username and password in the URL when the browser is loaded, like driver.get('https://username:[email protected]'). I'm not having any luck with this either; it simply brings up the same splash screen and asks for credentials, just like if I had manually clicked the 'login' button on the splash screen.

Does anyone have any ideas on this? It seems like it would be fairly straightforward since the cursor is already active in the username text box. Thanks for any help and advice!

Screenshot

3
You can use Selenium to target any DOM structure; not just elements with IDs or classes. What does the login box's HTML structure look like? Can you update the question to showcase that please? - Obsidian Age
I can't seem to find anything about the HTML structure of the login box. I can't right-click on it and inspect the elements, and on the HTML side, all I see is the HTML for the splash screen--there's nothing there for the login box. - drummingrocks
You can always use CTRL + U to view a source, or F12 for the Developer Tools. Surely the parent (or nearby element) has a unique identifier that you can make use of. - Obsidian Age
I thought the same thing, but if it's there, I'm not seeing it. Let me post a screenshot. - drummingrocks
Added screenshot at the bottom of the post. - drummingrocks

3 Answers

0
votes

I too faced similar issue while logging into the application. Since the windows authentication popup opened for login is not browser based popup, so selenium cannot interact with it directly. To interact with windows based popup, you have to use third party tool like AutoIT. After doing setup for AutoIT you just have to add one line of code as shown below after your url

driver.get("http://your.url");
Runtime.getRuntime().exec("D:\\AutoIt\\AutoItTest.exe");//path where you kept exe file 

For more info on how work on AutoIT, check second approach here or go through this article

0
votes

You can also directly insert the username and password into the Url.

Example: http://username:[email protected]

So in code you can say (in c#)

string yourUrl = "http://"+username+":"+password+"@yourUrl.com";
driver.Url = yourUrl;

Or java

String yourUrl = "http://"+username+":"+password+"@yourUrl.com";
driver.get(yourUrl);
0
votes

I ended up using AutoIT and writing a simple script for it to handle the login window. This was what I used:

Send("{TAB}{ENTER}")
Sleep(2000)
Send("user{TAB}password{ENTER}")

I called the AutoIT script within Selenium with this Javascript function:

function autoIT() {
    var child_process = require('child_process');
    var workerProcess = child_process.execFile("C:\\Selenium\\autoitscript.exe");
    sleep(4500).then(() => {
siteNavigate();
});

After the AutoIT script runs, you can then move back to using Selenium.