Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

click button of a pop up in webdriver

View previous topic View next topic Go down

click button of a pop up in webdriver

Post by sanjeetravi on Wed Jul 11, 2012 12:50 pm

HOW TO CLICK A OK BUTTON PRESENT IN A POPUP.

sanjeetravi
Regular Participant
Regular Participant

Posts : 27
Join date : 2012-07-10
Age : 26
Location : Delhi

Back to top Go down

Re: click button of a pop up in webdriver

Post by popsha on 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();

popsha
Amateur
Amateur

Posts : 60
Join date : 2012-04-14

Back to top Go down

Re: click button of a pop up in webdriver

Post by sanjeetravi on Mon Jul 16, 2012 11:54 am

But how will i found the name of the pop up window.??

sanjeetravi
Regular Participant
Regular Participant

Posts : 27
Join date : 2012-07-10
Age : 26
Location : Delhi

Back to top Go down

Re: click button of a pop up in webdriver

Post by popsha on Mon Jul 16, 2012 1:28 pm


popsha
Amateur
Amateur

Posts : 60
Join date : 2012-04-14

Back to top Go down

Re: click button of a pop up in webdriver

Post by sanjeetravi on 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();

}

}

sanjeetravi
Regular Participant
Regular Participant

Posts : 27
Join date : 2012-07-10
Age : 26
Location : Delhi

Back to top Go down

Re: click button of a pop up in webdriver

Post by naveenkhunteta on 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.

naveenkhunteta

Posts : 2
Join date : 2012-07-18

Back to top Go down

Re: click button of a pop up in webdriver

Post by naveenkhunteta on 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);

naveenkhunteta

Posts : 2
Join date : 2012-07-18

Back to top Go down

Re: click button of a pop up in webdriver

Post by Sponsored content Today at 3:23 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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