chanti
chanti

Reputation: 431

How to pass control to new window in selenium webdriver

There is a button in my application, which on click opens up a new window.

How can I verify the text in a new window?

I am using selenium web driver and Firefox browser.

Upvotes: 0

Views: 5631

Answers (2)

Rahul Das
Rahul Das

Reputation: 74

public String y[][];
public int size,i=0;

public void Get_Windows**`strong text`**()
{
    Set<String> Handle = driver.getWindowHandles();
    size= Handle.size();
    String[] Temp = Handle.toArray(new String[size]);
    String Tab_Id_Container[][]=new String[size][size];

    while(size>0)
    {
        driver.switchTo().window(Temp[i]);
        Tab_Id_Container[i][0]=driver.getTitle();
        Tab_Id_Container[1][i]=driver.getWindowHandle();
        System.out.println("Page name : "+Tab_Id_Container[i][0]);
        System.out.println("Hex value : "+Tab_Id_Container[1][i]);
        i++;
        size--;
    }


}

Try this one modify for your use

Upvotes: 0

Arun
Arun

Reputation: 875

You can do it with two ways.

1st use method

driver.switchTo().ActiveElement();

2nd

driver.switchTo().window("New Widnow tile")

Pass new window title as Parameter.

Upvotes: 4

Related Questions