Unable to switch to Body of the Gmail (Email-Compose box), Iframe does not have any id

227 views
Skip to first unread message

neeraj bakhtani

unread,
Sep 15, 2013, 1:40:57 AM9/15/13
to seleniu...@googlegroups.com

Hi friends,
I am unable to switch to Body of the Gmail (Email-Compose box)
Iframe does not have any id

I am using following code
driver.switchTo().frame(driver.findElement(By.tagName("iframe")));
driver.findElement(By.xpath("//*[starts-with(@class,'editable')]")).click();---->xpath of Body

but its not working.
Pls let me know whats wrong here...!!
Pic is attached
gmail.jpg

Srikanth

unread,
Sep 15, 2013, 2:52:26 AM9/15/13
to seleniu...@googlegroups.com

Try this & let me know if it doesn't work for you.


driver.switchTo().frame(driver.findElement(
   
By.xpath("//iframe[contains(@tabindex,'1') and contains(@frameborder,'0')]"))); //Switching to iframe
driver
.findElement(By.xpath("//body[@role='textbox']")).sendKeys("XXXXXXXXXX");    //Typing text into Email body
driver
.switchTo().defaultContent();        //switching back out from iframe


Thanks,

Srikanth

neeraj bakhtani

unread,
Sep 15, 2013, 3:08:57 AM9/15/13
to seleniu...@googlegroups.com
Hey Thanks
Srikanth that worked like a charm....:)


--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/ny3Q517RXrM/unsubscribe.
To unsubscribe from this group and all its topics, 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/52037e48-ce45-4b02-bf39-3a8556a0eb68%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Oscar Rieken

unread,
Sep 15, 2013, 10:08:39 AM9/15/13
to seleniu...@googlegroups.com
I would suggest that you don't try to write automation against gmail unless you work for google. There are a bunch of threads as to why you shouldn't 
Here is one 


--
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.

john.t...@jorsek.com

unread,
Sep 27, 2013, 3:23:34 PM9/27/13
to seleniu...@googlegroups.com
Thank you Srikanth! 

I'm taking Oscar.Rieken's comments to heart, but it this does work (now) and I'm glad you showed us how.

jat
Reply all
Reply to author
Forward
0 new messages