- sanjeetraviRegular Participant
- Posts : 27
Join date : 2012-07-10
Age : 34
Location : Delhi
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.
- popshaAmateur
- Posts : 60
Join date : 2012-04-14
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();
driver.switchTo().window(windowname);
//click the button with any attribute
driver.findElement(By.xpath).click();
- sanjeetraviRegular Participant
- Posts : 27
Join date : 2012-07-10
Age : 34
Location : Delhi
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.??
- popshaAmateur
- Posts : 60
Join date : 2012-04-14
Re: click button of a pop up in webdriver
Mon Jul 16, 2012 1:28 pm
Think this link should help you
https://seleniumforum.forumotion.net/t1298-how-to-switch-window-in-webdriver
https://seleniumforum.forumotion.net/t1298-how-to-switch-window-in-webdriver
- sanjeetraviRegular Participant
- Posts : 27
Join date : 2012-07-10
Age : 34
Location : Delhi
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();
}
}
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();
}
}
- naveenkhunteta
- Posts : 2
Join date : 2012-07-18
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.
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.
- naveenkhunteta
- Posts : 2
Join date : 2012-07-18
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);
//it will return all the FF windows Ids used by webdriver and capture these in a set collection.
set
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);
- Click on a button with no Id using Webdriver
- (Selenium Webdriver) Not able to click BROWSE button while uploading a file in GWT Framework
- Selenium Webdriver unable to click the submit button for the Second time after entering the datas from the excel
- Text Generation based on button click
- Select the “back” button of the Firefox browser to right click and Select the Option from the right click Menu in Selenium Web Driver - Java
Permissions in this forum:
You cannot reply to topics in this forum