Re: how to make test automated script for insert text in google docs spreadsheet with selenium ide

2,169 views
Skip to first unread message

Tarun Kumar

unread,
May 10, 2013, 2:49:28 AM5/10/13
to seleniu...@googlegroups.com
Though I never tried it Selenium IDE + Google DOC, I am curious to know why would you do that?

On Friday, May 10, 2013 10:27:42 AM UTC+5:30, Mayank Chauhan wrote:
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

Gustavo Godoy

unread,
May 10, 2013, 9:29:58 AM5/10/13
to seleniu...@googlegroups.com
I do not even do this before, but besides your urgency, try some googling to googles doc api. I read some time ago that googles API do this things you want, and its not selenium... You don't interact with browser to do, just access docs and edit them.

as I said, I don't used it but try to search some tutorials related to it

thanks

Gustavo Godoy

Arpan Buch

unread,
Dec 2, 2013, 7:02:36 AM12/2/13
to seleniu...@googlegroups.com

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();

        }
    }













On Monday, May 20, 2013 5:37:05 PM UTC+5:30, Mayank Chauhan wrote:
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.
Reply all
Reply to author
Forward
0 new messages