0

I am not able to map the elements of the prompt because it is not possible to inspect them to get the ID or name of the login and password fields, I'm trying to code the code below, give a tab in the elements and even without success.

How do I automate login on this interface?

    driver.get("url");
    Alert alert = driver.switchTo().alert();
    Thread.sleep(2000);
    Robot robot = new Robot();
    robot.keyPress(KeyboardEvent.DOM_VK_TAB);

login

Abhijit
  • 374
  • 3
  • 15
Paulo Roberto
  • 1,498
  • 5
  • 19
  • 42
  • Why is it impossible to inspect the elements? – Bill Hileman Oct 08 '18 at 18:04
  • @BillHileman Nothing happens when I press F12, in chrome, or CTRL + U, to display the source code. Therefore, I can not inspect the elements of the page. – Paulo Roberto Oct 08 '18 at 18:07
  • I've never heard of such a thing. I take it you can't share the URL? Have you tried other browsers? – Bill Hileman Oct 08 '18 at 18:37
  • Also, have you tried using getPageSource? – Bill Hileman Oct 08 '18 at 18:38
  • @BillHileman I tried it in other browsers and the result is the same, I also used the String command pageSource = driver.getPageSource (); it's nothing. the URL is as follows: http://sharepoint.infoserver.com.br/ – Paulo Roberto Oct 09 '18 at 13:47
  • That's not a regular alert. In fact, it might not even be part of the browser, it is likely part of the operating system, and I don't know that it can be automated in any way. You may have to manually log-in before you start your automation script(s), or this simply may not be capable of being automated at all. Sorry I wasn't able to be more help. – Bill Hileman Oct 09 '18 at 13:54
  • 1
    Paulo, Bill is correct that selenium will not be able to interact with this type of login. You can look here for other solutions: https://stackoverflow.com/questions/47005817/logging-in-using-javascript-and-selenium-webdriver-chrome – Michiel Bugher Oct 09 '18 at 16:14
  • This approach currently does not work in Google Chrome. In Firefox OK. – pburgr Oct 10 '18 at 07:10

1 Answers1

0

This seems to be a basic authentication popup. You can resolve it by passing the credentials in the URL itself as below:

driver.get("http://<username>:<password>@www.example.com");

Kireeti Annamaraj
  • 1,037
  • 1
  • 8
  • 12