unable to identify the Xpath for the signout in gmail.

571 views
Skip to first unread message

dvramana

unread,
Nov 21, 2011, 4:47:00 AM11/21/11
to Selenium Users
Hello All,

I'm Facing a problem for the signout session in gmail.The thing is
that i have used Xpath for the signout and tool is unable to identify
the xpath during the execution.

Could any one help me in solving this issue and please look at the
code below for reference

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.android.AndroidDriver;

import com.thoughtworks.selenium.Selenium;

public class mobile {

public static void main(String[] args) throws Exception

{
// TODO Auto-generated method stub

String baseUrl = "http://gmail.com";
AndroidDriver driver = new AndroidDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.open("http://gmail.com");
Thread.sleep(1000);
driver.findElement(By.id("Email")).sendKeys("xxxxx");
Thread.sleep(1000);

driver.findElement(By.id("Passwd")).sendKeys("12345");
Thread.sleep(8000);

driver.findElement(By.name("signIn")).click();
Thread.sleep(80000);
driver.findElement(By.xpath("//div[@id='tltbt']/div/div/
div")).click();

Here from the above the tool is unable to find the Xpath showing the
error as

Exception in thread "main" org.openqa.selenium.NoSuchElementException:
Could not find element with xpath: //div[@id='tltbt']/div/div/div
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Linux', os.arch: 'armv5tejl', os.version:
'2.6.29-gb0d93fb-dirty', java.version: '0'

bs

unread,
Nov 21, 2011, 7:50:44 AM11/21/11
to Selenium Users
If the "@id" is changing, XPath will fail. If that is the case, use -
("//*[contains(@id,'titb')]")

Mark Collin

unread,
Nov 21, 2011, 8:09:29 AM11/21/11
to seleniu...@googlegroups.com
Gmail is riddled with frames, it's probably hidden in its own frame you need
to switchTo()

Hello All,

import com.thoughtworks.selenium.Selenium;

public class mobile {

--
You received this message because you are subscribed to the Google Groups
"Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to
selenium-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/selenium-users?hl=en.


--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

If you have received this email in error please notify postm...@ardescosolutions.com

Ramana

unread,
Nov 21, 2011, 8:23:15 AM11/21/11
to seleniu...@googlegroups.com
Hi BS,
 
i have tried using the ("//*[contains(@id,'titb')]") but again it is throwing the error as

Exception in thread "main" org.openqa.selenium.WebDriverException: Error: {"message":"Unable to locate an element with the xpath expression \/\/*contains[@id='titb']\/div\/div\/div because of the following error:\nError: INVALID_EXPRESSION_ERR: DOM XPath Exception 51"}

Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

System info: os.name: 'Linux', os.arch: 'armv5tejl', os.version: '2.6.29-gb0d93fb-dirty', java.version: '0'

Driver info: driver.version: EventFiringWebDriver; duration or timeout: 998 milliseconds.

Ramana

unread,
Nov 21, 2011, 8:25:58 AM11/21/11
to seleniu...@googlegroups.com
Hello collin,
 
I'm new to the selenium,
 
i will be very thankfull to you if you can elobrate the solution for this.

Mark Collin

unread,
Nov 21, 2011, 9:07:08 AM11/21/11
to seleniu...@googlegroups.com

Look ath the HTML source for Gmail and see if the element you are looking for is inside either an iFrame or a Frame.  If it is you need to switch to the frame before you will be able to access the element that you are trying to click on.  The WebDriver way to switch frames is:

 

WebElement myFrame = driver.findElement(By.xpath("//iframe"));

driver.switchTo().frame(myFrame);

Ramana

unread,
Nov 21, 2011, 10:32:28 AM11/21/11
to seleniu...@googlegroups.com
Hello Collin,

Thanks for the reply.

i have tried to get the iframe from the page sourse,but to my badluck it is not availabe.

Any other workaround for this?

Mark Collin

unread,
Nov 21, 2011, 11:57:14 AM11/21/11
to seleniu...@googlegroups.com

Yes it is, you need to look at the page source for the default page:

 

//iframe[@id='canvas_frame']

 

Gmail is not a good place to start leaning selenium it has some very complicated and convoluted HTML and is very hard to keep track of.  You need a very good understanding of HTML and locator strategies to be able to automate it.

 

I would suggest starting on something a little less complex.

Ramana

unread,
Nov 22, 2011, 2:23:20 AM11/22/11
to seleniu...@googlegroups.com
Hello mark,
 
Thanks for the reply.
 
Ss you said in the below mail to use the one which is less complicated, so  i have tried on mail.in.com site rather than gmail.and here i could able to run the tests using Xpath.
 
Cheers
venkat

Reply all
Reply to author
Forward
0 new messages