Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
sanjeetravi
sanjeetravi
Regular Participant
Regular Participant
Posts : 27
Join date : 2012-07-10
Age : 33
Location : Delhi

click button of a pop up in webdriver Empty click button of a pop up in webdriver

Wed Jul 11, 2012 12:50 pm
HOW TO CLICK A OK BUTTON PRESENT IN A POPUP.
avatar
popsha
Amateur
Amateur
Posts : 60
Join date : 2012-04-14

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Wed Jul 11, 2012 1:56 pm
//focus to the popup window using
driver.switchTo().window(windowname);

//click the button with any attribute
driver.findElement(By.xpath).click();
sanjeetravi
sanjeetravi
Regular Participant
Regular Participant
Posts : 27
Join date : 2012-07-10
Age : 33
Location : Delhi

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Mon Jul 16, 2012 11:54 am
But how will i found the name of the pop up window.??
avatar
popsha
Amateur
Amateur
Posts : 60
Join date : 2012-04-14

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Mon Jul 16, 2012 1:28 pm
sanjeetravi
sanjeetravi
Regular Participant
Regular Participant
Posts : 27
Join date : 2012-07-10
Age : 33
Location : Delhi

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Wed Jul 18, 2012 1:20 pm
Here is my code the id of my popup is "companySelectionPopup" by using the above commands its still shows the error that unable to find element with id j_idt76:j_idt82.

Somebody pls help its a big bottle neck for me as my project is full off popups
private WebDriver driver;
private String baseUrl;
String newSet;


@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://192.168.0.101:7001/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}




@Test
public void Test7()throws Exception {
driver.get(baseUrl + "/SimonWeb/login.html");
driver.findElement(By.id("submit")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
newSet=driver.getWindowHandle();
driver.switchTo().window(newSet);
driver.findElement(By.id("j_idt76:j_idt82")).click();
}
@After
public void tearDown() throws Exception {
http://driver.quit();

}

}
avatar
naveenkhunteta
Posts : 2
Join date : 2012-07-18

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Wed Jul 18, 2012 6:19 pm
Hi Sanjit,

Is it a Java script pop-up or some window pop-up?
or its a kind of java script alert?

In webdriver, we have 3 different ways of handling these pop-ups and alerts.
try following code:

WebDriver driver=new FirefoxDriver();

Alert alert=driver.switchTo().alert(
); //Alert is an interface in Selenium and switchTo() and alert() are static methods of it.
alert.accept(); // it will click on OK button
alert.dismiss(); // it will click on Cancel button.
alert.getText(); // it will capture the text present on alert.
avatar
naveenkhunteta
Posts : 2
Join date : 2012-07-18

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Wed Jul 18, 2012 7:40 pm
And if its a pop up window try the following code----

//it will return all the FF windows Ids used by webdriver and capture these in a set collection.
set windowIds=driver.getWindowHandles();

Iterator itr=windowIds.iterator();
while (itr.hasNext()){
mainwindowID=itr.next(); // main window ID
popupwindowID=itr.next(); // pop-up window ID
}

driver.switchTo().window(popupwindowID);

//clicking on Ok button
driver.findElement(By.Xpath("---xpath of Ok button----")).Click

//Switch back to the main window pop-up
driver.switchTo().window(mainwindowID);
Sponsored content

click button of a pop up in webdriver Empty Re: click button of a pop up in webdriver

Back to top
Permissions in this forum:
You cannot reply to topics in this forum