0
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://52.19.191.249/aur/");
driver.switchTo().alert().sendKeys("username");
driver.switchTo().alert().sendKeys("password");
driver.switchTo().alert().accept();

Getting message as no alert open

Keyur Potdar
  • 7,158
  • 6
  • 25
  • 40
  • Possible duplicate of [Selenium - Other way to basic authenticate than via url](https://stackoverflow.com/questions/45345882/selenium-other-way-to-basic-authenticate-than-via-url) – undetected Selenium Sep 14 '17 at 12:41
  • Possible duplicate of [How to perform Basic Authentication for FirefoxDriver, ChromeDriver and IEdriver in Selenium WebDriver?](https://stackoverflow.com/questions/5672407/how-to-perform-basic-authentication-for-firefoxdriver-chromedriver-and-iedriver) – Amol Chavan Sep 14 '17 at 12:50
  • This is not duplicate i am trying to authenticate the internal site not the hosted one – irshadmohammed yakubkhan Sep 14 '17 at 13:04

3 Answers3

3

Since driver.switchTo().alert() doesn't wait for alert loaded, you need to wait for it. See https://stackoverflow.com/a/12639803/8609512

P.S. You can check it by adding a Thread.sleep(2000); for example, before driver.switchTo().alert().sendKeys("username"); sentence -- sleeps are usually a bad practice for test automation, but sometimes it could be helpful in debugging.

0

Tried with this syntax and worked driver.get("http://Username:password@52.19.191.249/aur/") ;

0

Try using autoit: [its simple and effective]

The code goes something like ::

from selenium import webdriver
import autoit
driver= webdriver.Chrome()
driver.get("http://sitewithpopup.com")
autoit.win_wait_active("",30) 
autoit.send("Username{TAB}")
autoit.send("Password{Enter}")

Since the autoit will type whereever your cursor is and by default the cursor is on the userID field so you can make use of it.