Unable to handle javascript prompt pop ups | Selenium Forum
M
Posted on 14/06/2016
Sir,

have a url, as soon as i navigate to that url, "authentication required" javascript prompt pop ups..This dialog pop up has textboxes
<username> ,<password>, buttons ok & cancel...

i need to switch to this alert & enter username, pwd & click ok....

[b:2e50mjss]Issue:[/b:2e50mjss][b:2e50mjss]:Switch to alert never takes place....[/b:2e50mjss]

[b:2e50mjss]Reference: code as below:[/b:2e50mjss]

package Ruff_structured_SCripts_CP;

import java.util.concurrent.TimeUnit;

import org.apache.http.auth.UsernamePasswordCredentials;
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.security.Credentials;

public class Doc_upload {

public static void main(String[] args) {
// TODO Auto-generated method stub
String userName="user1";
WebDriver w=new FirefoxDriver();
w.get("sonso");
w.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
System.out.println("wait ended");
try{
Alert alert=w.switchTo().alert();
//w.switchTo().alert().authenticateUsing((Credentials) new UsernamePasswordCredentials(userName, "Password1090"));
//alert.accept();
alert.dismiss();
alert=w.switchTo().alert();
alert.dismiss();
//System.out.println(alert.getText());
System.out.println("alert handling ended");
}
catch(Exception e)
{
System.out.println("unble to switch to alert");
System.out.println(e.getMessage());
System.out.println(e.getStackTrace());
}


}

}

[b:2e50mjss]Issue:[/b:2e50mjss][b:2e50mjss]:Switch to alert never takes place....[/b:2e50mjss] [b:2e50mjss]& NO Exception occurs [/b:2e50mjss]
[b:2e50mjss]Request for your inputs sir[/b:2e50mjss]

M
Replied on 14/06/2016

you have yo do it AutoIT.


M
Replied on 14/06/2016

Sir, am trying to use AUTOIT, this dialogue box is shown as "[b:7lhmwsah]Mozilla Dialog Class[/b:7lhmwsah]"
& when i drag the FinderTool on to "username" or password textbox..the details of "username" or "password" textbox are not shown in
"AutoIT window info"

PLs refer attachments

[b:7lhmwsah]Query:Is AutoIT not showing up dialogue properties bcoz its browser's dialogue box , not windows os 's?
Sir pls suggest [/b:7lhmwsah]

Responsive image

M
Replied on 15/06/2016

Sir, as u said AUTOIT is the solution...

I scripted like this:UploadFile.
-----------------
WinActivate("Authentication Required")
Send("user1")
Send("{TAB}")
Send("Password1090")
Send("{ENTER}")


-----in my java file-----
get the url
Runtime.getRuntime().exec("path");


[b:ll6t1qdh]Sir, This works wierd....i have to click close button of Authentication required prompt twice, then it writes the username & pwd.....
I think my script is wrong , i want to record my action in script .[/b:ll6t1qdh]

[b:ll6t1qdh]Request: Could you please give me a link to "how to use" -record n play feature of AutoIT..?[/b:ll6t1qdh]


M
Replied on 15/06/2016

Thankz sir ..Issue is resolved...