Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

View previous topic View next topic Go down

HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

Post by bhasker on Tue Jul 17, 2012 7:06 pm

HI,
I got a issue whille selecting an element from lookup (new window).I tried to the window title but unable to retrieve the window tile(using get window handls method)

bhasker
Active particpant
Active particpant

Posts : 18
Join date : 2012-06-11

Back to top Go down

Re: HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

Post by PonAruna on Wed Jul 18, 2012 1:29 am

try

dr1.switchTo().window("popupwindow");
("popupwindow" is the window name)
or

for (String handle : dr1.getWindowHandles()) {
dr1.switchTo().window(handle);
}

PonAruna

Posts : 5
Join date : 2012-07-06

Back to top Go down

Re: HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

Post by bhasker on Wed Jul 18, 2012 11:39 am

i tried in both ways but iam unable to switch to new window .is there any other method other these two

bhasker
Active particpant
Active particpant

Posts : 18
Join date : 2012-06-11

Back to top Go down

Re: HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

Post by PonAruna on Wed Jul 18, 2012 9:17 pm

Hi

I believe you are trying this in either Selenium RC or webdriver

because either of this should work

I think you should try with some other example than with the one you are trying currently

give a try

import junit.framework.Assert;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;


public class PopupWindow {

public static void main(String[] args){

WebDriver dr1=new FirefoxDriver();
dr1.get("http://book.theautomatedtester.co.uk");
WebElement linkChapter1=dr1.findElement(By.linkText("Chapter1"));
linkChapter1.click();
System.out.println(dr1.getTitle());
WebElement multipleWindowLink = dr1.findElement(By.xpath(".//*[@id='multiplewindow']"));
multipleWindowLink.click();

// Accessing the window by window Name
http://dr1.switchTo().window("popupwindow");

// alternate method to access the popup window if the window name is not known
for (String handle : dr1.getWindowHandles()) {
dr1.switchTo().window(handle);
}
Assert.assertEquals(dr1.findElement(By.xpath("//*[@id='popuptext']")).getText(), "Text within the pop up window");

WebElement popupWindowClose = dr1.findElement(By.xpath("//*[@id='closepopup']"));
popupWindowClose.click();
for (String handle : dr1.getWindowHandles()) {
dr1.switchTo().window(handle);
}
System.out.println(dr1.getTitle());
dr1.quit();
}

}

PonAruna

Posts : 5
Join date : 2012-07-06

Back to top Go down

Re: HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

Post by popsha on Thu Jul 19, 2012 11:13 am

hope viewing this link would find a perfect solution for you.

http://seleniumforum.forumotion.net/t1298-how-to-switch-window-in-webdriver

popsha
Amateur
Amateur

Posts : 60
Join date : 2012-04-14

Back to top Go down

Re: HOW TO HANDLE LOOKUP(NEW WINDOW ) IN SELENIUM

Post by Sponsored content Today at 4:48 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