Not able to enter text in username and password text box and click on sign in button inside Javascript prompt box | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
15% Colorful Festival Offer Avail now

Selenium Training Forum

Not able to enter text in username and password text box and click on sign in button inside Javascript prompt box

S
suhail.itm Post on 15/03/2019

I launched website http://the-internet.herokuapp.com/  and click the 2 link Basic Auth (user and pass: admin). a javascript prompt box appear which asked me to login . how to automate with selenium . i tried below code .

 

System.setProperty("webdriver.chrome.driver", "E:\\Driver\\chromedriver.exe");

System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, "null");

System.setProperty(ChromeDriverService.CHROME_DRIVER_SILENT_OUTPUT_PROPERTY, "true");

ChromeOptions op=new ChromeOptions();

op.addArguments("--disable--notifications");

op.addArguments("disable-infobars");

WebDriver driver=new ChromeDriver(op);

driver.get("http://the-internet.herokuapp.com/");

driver.manage().window().maximize();

driver.findElement(By.xpath("//a[contains(.,'Basic Auth')]")).click();

Thread.sleep(10000);

Alert alert=driver.switchTo().alert();

alert.sendKeys("admin");

alert.sendKeys("admin");

alert.accept();

D

Instructor

Demo Reply on 15/03/2019

You have to manage it using AutoIT or Robot class.

S
suhail.itm Reply on 18/03/2019

Hi Ashish ,

I have tried with AutoIT , It recognizes all element as intermediate D3D windows and not able to perform any action .kindly help me .

Regards

Suhail

D

Instructor

Demo 5 days go

Please try using robot class