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

3

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Tried with this syntax and worked driver.get("http://Username:[email protected]/aur/") ;

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.