how to make test automated script to insert text in google docs spreadsheet with selenium ide in a particular row of a column?
for example if i want to insert "hello" in 2nd row and 3rd column. i am able to locate the particular column and row with the help of XPATH but not able to insert the text. Need full help is appreciable. ASAP
package com.google;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
public class testgoogle {
static WebDriver driver;
static WebElement element;
public static void main(String args[]) throws InterruptedException{
driver = new FirefoxDriver();
driver.get("http://www.gmail.com");
//sign in
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("Email")).sendKeys("username");
driver.findElement(By.id("Passwd")).sendKeys("password");
driver.findElement(By.id("signIn")).click();
//sleep till page is loaded --necessary
Thread.sleep(15000);
String parentHandle = driver.getWindowHandle();
driver.findElement(By.xpath(".//*[@id='gbwa']/div[1]/a")).click();
driver.findElement(By.id("gb25")).click();
//Perform the click operation that opens new window
System.out.println("this one should be the gmail" + driver.getCurrentUrl());
// switching the window to google drive
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
}
System.out.println("this one should be the google drive" + driver.getCurrentUrl());
element = driver.findElement(By.xpath(".//*[@id='navpane']/div[2]/div[1]/div/div/div[1]"));
new Actions(driver).moveToElement(element).click().perform();
driver.findElement(By.xpath(".//*[@id=':1t.cmi']")).click();
// switching it to google sheet window from google drive window
String parent2Handle = driver.getWindowHandle();
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
Thread.sleep(1000);
}
System.out.println("this one should be the spread sheet" + driver.getCurrentUrl());
Thread.sleep(5000);
driver.findElement(By.xpath("//table/tbody/tr/td[3]/div/div/div")).sendKeys("hello this is first field");
driver.close();
// accept the leave window alert.
Alert alert = driver.switchTo().alert();
alert.accept();
//closes the google drive window
driver.switchTo().window(parent2Handle);
driver.close();
// closes the gmail window
driver.switchTo().window(parentHandle);
driver.close();
}
}Task Accomplished through WebDriver.
here is the code..
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://docs.google.com/spreadsheet /ccc?key=0AlRwE2ujWmtrdGtpWm5sQ2NSdjJkT3BULUpWR21ma1E#gid=0");
driver.findElement(By.id("Email")).sendKeys("***********");
driver.findElement(By.id("Passwd")).sendKeys("**********");
driver.findElement(By.id("signIn")).click();
driver.findElement(By.xpath("//tr[@id='0-r-column-head-section$3']/td[4]")).click();
driver.findElement(By.xpath("//table/tbody/tr/td[3]/div/div/div")).click();
driver.findElement(By.xpath("//table/tbody/tr/td[3]/div/div/div")).sendKeys("Hello World!");
driver.findElement(By.xpath("//tr[@id='0-r-column-head-section$3']/td[5]")).click();
thanks to all.
Life is Good..!!
On Friday, May 10, 2013 10:49:55 PM UTC+5:30, Mayank Chauhan wrote:ok. thanks, i will give it a try. i have already made a test automated script to insert text in www(dot)docs(dot)com spreadsheet and its working fine. but with googledocs not able to insert it. Just able to double in particular column. its a task given to me so i thought here i can get help.