How to get back control to page1 after going to page2 by clicking on link in page1

32 views
Skip to first unread message

messia660

unread,
Mar 10, 2013, 11:27:59 AM3/10/13
to indian-seleni...@googlegroups.com
Hello,
In a page that I'm finding elements there is a link to google, now if we run the following code it will find the elements on my test page, and then it either clicks or sendkeys.

In test page there is a link to go to google, when this element is clicked, the google page opens, and the execution stops, how to come back to my test page after google is open, so that remaing elements can be tested?

package com.qspiders;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class Find_element_send_click {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();

//get the page
driver.get("file:///F:/selenium/selenium_tool/web_driver_projects/test.html");
WebElement element = driver.findElement(By.id("un"));
element.sendKeys("admin");
//element.clear();
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.xpath("//input[@type='checkbox']")).click();
driver.findElement(By.linkText("Google")).click();
driver.findElement(By.xpath("//textarea")).sendKeys("this is text area");
driver.findElement(By.xpath("//input[@type='file']")).sendKeys("F:\\selenium\\selenium_tool\\web_driver_projects\\asd.docx");
driver.findElement(By.xpath("//input[@type='button']")).click();
driver.findElement(By.xpath("//input[@type='radio']")).click();

//select
WebElement selement = driver.findElement(By.xpath("//select[@name = 'city']"));
Select s = new Select(selement);
s.selectByVisibleText("Hubli");

//multi select
WebElement mselement = driver.findElement(By.xpath("//select[@name = 'city1']"));
Select mselement1 = new Select(mselement);
mselement1.selectByVisibleText("Mumbai");
mselement1.selectByVisibleText("Bangalore");
mselement1.deselectByVisibleText("Mumbai");
}
}

Reply all
Reply to author
Forward
0 new messages