How to sendKeys to Google Docs

1,035 views
Skip to first unread message

Tiếu Thủy

unread,
Nov 18, 2014, 1:43:32 AM11/18/14
to seleniu...@googlegroups.com
Dear all

I am trying to apply Selenium Java 2.44.0 with Google Docs (docs.google.com)

I can get the content of Google Docs document by

WebElement e = driver.findElement (byClassName ("kix-lineview")); //driver is a FirefoxDriver

then

e.getText ( );

but when I tried:

e.sendKeys ("abc");


nothing happened

If you have experience to sendKeys to Google Docs document, could you please help me?

Thank you very much


pranab singh

unread,
Nov 18, 2014, 3:24:24 AM11/18/14
to seleniu...@googlegroups.com

Hey if their is a space to put the path of a file then only the send keys will work fine.
The web element  must be a text field to work with sendkeys.and then u can press enter.eg.
e.sendkeys("abc or whatever u want to search",Keys.Enter);
Hope this may work fine..n let me know

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f6bf1c70-c118-4182-89c9-29c1f67c9c93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tiếu Thủy

unread,
Nov 21, 2014, 5:23:49 AM11/21/14
to seleniu...@googlegroups.com
Hello Paranab

Thank you very much for your help, but it does not work.

Basically, I want to sendKeys (to type) in Google Docs document.

PeterJeffreyGale

unread,
Nov 21, 2014, 5:35:28 AM11/21/14
to seleniu...@googlegroups.com
Tieu

It is not enough information to just say that "it doesn't work".

At least give th actual code that you have tried and full details of any error messages.

Tiếu Thủy

unread,
Nov 23, 2014, 4:26:21 AM11/23/14
to seleniu...@googlegroups.com

Hello Peter

I am sorry for the lack of information:

The code I am using is as follow;


WebDriver driver = new FirefoxDriver ();

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

driver.get ("Google Docs URL HERE");

WebElement content = driver.findElement(By.className("kix-lineview"));

System.out.println("found");

while (true) {

    System.out.println (content.getText ()); //it works, the content of the document is printed to console  

    content.sendKeys("abc"); // it does not work: the content does not change

}


But I realized that, during the code runs, if I clicked to the document content manually, the text "abc" will be append. But if I do not click and let the code run, the content of the document does not change.

I also tried:

content.click ();

before

content.sendKeys ("abc");

but it still does not help. The content of the document does not change

Tiếu Thủy

unread,
Nov 26, 2014, 3:11:49 AM11/26/14
to seleniu...@googlegroups.com
Hello,

I am still stuck with this problem.

Any hint is appreciated

CH!NN@ K

unread,
Nov 26, 2014, 3:53:33 AM11/26/14
to seleniu...@googlegroups.com
Hi Tieu Thuy, I think what is the problem is you can use xpath at className (because google docs and gmail some time change the locators/elements frequently  ). So better to use xpath instead of className. I guess that.   (WebElement content = driver.findElement(By.className("kix-lineview"));
(WebElement content = driver.findElement(By.xpath("//*[ XXXXXXXXXXXXXXXXXXXX] "));

---
Thanks & Regards,
Purushotham Karimbedu,
Druapl Developer and QA Engineer,
Website for Selenium : http://techlearn.in


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages