Webdriver xpath is not working

2,749 views
Skip to first unread message

Hari

unread,
Jul 8, 2012, 4:44:10 AM7/8/12
to seleniu...@googlegroups.com
Hi,
I having the scenario of expanding the tree. 
   
   In selenium RC with IE and FF , its working fine

Selenium RC

selenium.click("xpath=//x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]");

But in the Webdriver its not working for both IE and FF

Selenium Webdriver

driver.findElement(By.xpath("/x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]")).click();

ERROR

org.openqa.selenium.InvalidSelectorException: The given selector /x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1] is either invalid or does not result in a WebElement. The following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath expression /x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1] 


Regards,
Hari

Peter Gale

unread,
Jul 8, 2012, 5:05:02 AM7/8/12
to Selenium Users
Try it with the "x:"'s omitted.

What are they for, I've not seen them before ... are they Selenium IDE notation rather than Xpath?

It's also very brittle Xpath so if you provide a full sample of the html someone might suggest a better XPath.

Sounds like you need to do a basic Xpath tutorial too, rather than just relying on record and playback type tools.


Date: Sun, 8 Jul 2012 14:14:10 +0530
Subject: [selenium-users] Webdriver xpath is not working
From: hari...@gmail.com
To: seleniu...@googlegroups.com
--
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-US.

Mark Collin

unread,
Jul 8, 2012, 5:30:01 AM7/8/12
to seleniu...@googlegroups.com

You’ll need to show us the XML.

 

My initial observation is that you are starting the Selenium xpath with // and the WebDriver one with / which could be why the WebDriver one is failing (that being said <html> is normally a root element so I would expect it to work assuming this is xhtml).

 

Secondly as peter mentions this is a very brittle XPath if you are testing a website, if you are testing an XML file which has been properly defined this is the recommended way to use XPath.  I’m guessing you are actually using xhtml though.

 

@Peter

 

Those are XML namespaces, they are not usually used in web pages, the default namespace is an empty string which is what is normally used by everybody.  Multiple namespaces can become a real pain in the arse (in my opinion from a testing point of view), especially when you don’t know in advance what all the namespaces are going to be.

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Hari
Sent: 08 July 2012 09:44
To: seleniu...@googlegroups.com
Subject: [selenium-users] Webdriver xpath is not working

 

Hi,

--

Peter Gale

unread,
Jul 8, 2012, 5:51:15 AM7/8/12
to Selenium Users
Ah, yes! namespaces ... we touched on them on our 3 day introductory course to all things XML ... think I blinked when they were mentioned and never did quite get the idea of them ... never seen them in use anywhere (yet) though, thankfully! :)

Thanks Mark


From: mark....@lazeryattack.com
To: seleniu...@googlegroups.com
Subject: RE: [selenium-users] Webdriver xpath is not working
Date: Sun, 8 Jul 2012 10:30:01 +0100

Hari

unread,
Jul 9, 2012, 2:40:10 AM7/9/12
to seleniu...@googlegroups.com
@Peter

Tried without using x:     Still facing the issue

@mark below is code

<html>
<head>
<body onload="parent.update_view();">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<nobr>
<a href="javascript:parent.update_tree(":", "expand");">
<img border="0" align="top" alt="Collapse tree view for node." src="images/treeglyphs/0011.gif"/>
</a>
<a href="javascript:parent.update_tree(":", "select");">
<a class="selectedTreeText" href="javascript:parent.update_tree(":", "select");">  Node</a>
</nobr>
</td>
</tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
</tbody>
</table>
<script language="javascript"> parent.selectedDepth = 0 ; </script>
</body>
</html>

Thanks & Regards
Hari

Reshma Bhanu

unread,
Jul 9, 2012, 2:49:48 AM7/9/12
to seleniu...@googlegroups.com
i hope,xpath should start with double slash,  "//"

try with //

Hari

unread,
Jul 9, 2012, 3:22:45 AM7/9/12
to seleniu...@googlegroups.com
We have been tried with the double slash // and single slash / . we are facing the same issue. can anybody help to getting the xpath value

Peter Gale

unread,
Jul 9, 2012, 3:50:02 AM7/9/12
to Selenium Users
I can't see any indication of namespaces in that html, so I'm still not sure what the necessity for the "x:" is, unless there's something more you're not showing us.


Also, I don't think you need the "[1]" after the "tr" and "a" elements, I usually have to leave this off to avoid my tests failing. I'm not sure what the standard says about the  use of [1] to identify the first element in a group.


Lastly, I'd point out that there is an opening "head" tag but not a closing one, but I don't think that should cause the error you mention.



Date: Mon, 9 Jul 2012 12:10:10 +0530
Subject: Re: [selenium-users] Webdriver xpath is not working
From: hari...@gmail.com
To: seleniu...@googlegroups.com

Mark Collin

unread,
Jul 9, 2012, 4:02:34 AM7/9/12
to seleniu...@googlegroups.com

You are missing the line(s) above the <html> element where the namespace would be defined.

 

If the page previously had namespaces and now no longer has then that would cause your xpath to break, but I would expect it to break across the board if this was the case.

 

Secondly, the <head> tag is not closed so body is now a child of head, not of html (this will break your xpath)

 

The rest look slike it should work.

Abhinav Vaid

unread,
Jul 9, 2012, 5:29:56 AM7/9/12
to seleniu...@googlegroups.com
Yes, Xpath is very brittle.
Anyways, try without 'x's in web driver or if possible save that test page as HTML and attach it with this thread. I can look at it after that.
 
Regards
Abhinav

Hari

unread,
Jul 9, 2012, 5:37:20 AM7/9/12
to seleniu...@googlegroups.com
Hi

I have attached the htlm souce page, Firebug info and  screen shot what we are doing.

We tried with the following xpath's. We faced the issue

driver.findElement(By.xpath("/html/body/table/tbody/tr[1]/td/nobr/a[1]")).click();

driver.findElement(By.xpath("//html/body/table/tbody/tr[1]/td/nobr/a[1]")).click();

driver.findElement(By.xpath("x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]")).click();


driver.findElement(By.xpath("/x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]")).click();

driver.findElement(By.xpath("//x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]")).click();



ERROR



org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//html/body/table/tbody/tr[1]/td/nobr/a[1]"}
Command duration or timeout: 30.05 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.22.0', revision: '17049', time: '2012-05-29 13:32:46'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: RemoteWebDriver
Session ID: 3a5a376c-7e6c-4b89-8a5a-24f6e050eb15
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:458)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:226)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:311)
    at org.openqa.selenium.By$ByXPath.findElement(By.java:343)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:218)
    at com.ibi.idp.test.One1.testOne1(One1.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to locate element: {"method":"xpath","selector":"//html/body/table/tbody/tr[1]/td/nobr/a[1]"}
Build info: version: '2.22.0', revision: '17049', time: '2012-05-29 13:32:46'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_22'
Driver info: driver.version: unknown
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/axtst079/LOCALS~1/Temp/anonymous8615889763516435965webdriver-profile/extensions/fxdr...@googlecode.com/components/driver_component.js:6564)
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/axtst079/LOCALS~1/Temp/anonymous8615889763516435965webdriver-profile/extensions/fxdr...@googlecode.com/components/driver_component.js:471)


Regards,
Hari


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/33EXyZzRRYoJ.
html.txt
screenshot1.JPG
screenshot2.JPG
screenshot3.JPG

Peter Gale

unread,
Jul 9, 2012, 5:44:20 AM7/9/12
to Selenium Users
Have you tried omitting the [1]'s as previously suggested?


Date: Mon, 9 Jul 2012 15:07:20 +0530
Subject: Re: [selenium-users] Re: Webdriver xpath is not working
From: hari...@gmail.com
To: seleniu...@googlegroups.com

Hari

unread,
Jul 9, 2012, 5:49:13 AM7/9/12
to seleniu...@googlegroups.com
yes peter i have tried without a[1]. Am using the a[1] to clicking the first tree.

In selenium RC working fine but in the Webdriver we are facing the issue

Mark Collin

unread,
Jul 9, 2012, 5:50:03 AM7/9/12
to seleniu...@googlegroups.com

The html you have provided is a series of frames, are you switching to the correct frame before performing the findElement?

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Hari
Sent: 09 July 2012 10:37
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Re: Webdriver xpath is not working

 

Hi

Peter Gale

unread,
Jul 9, 2012, 5:58:10 AM7/9/12
to Selenium Users
I can't see this in your list:

driver.findElement(By.xpath("/html/body/table/tbody/tr/td/nobr/a")).click();

Nor have you included the head element (which Mark pointed out would break your test) in any of your examples.




Date: Mon, 9 Jul 2012 15:19:13 +0530

Hari

unread,
Jul 9, 2012, 6:38:38 AM7/9/12
to seleniu...@googlegroups.com
@Mark we are switching to the correct frame

@Peter we tried at below one what u gave. we facing the issue

driver.findElement(By.xpath("/html/body/table/tbody/tr/td/nobr/a")).click();

org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"/html/body/table/tbody/tr/td/nobr/a"}
Command duration or timeout: 30.09 seconds

For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.22.0', revision: '17049', time: '2012-05-29 13:32:46'

Regards,
Hari

Mark Collin

unread,
Jul 9, 2012, 6:46:04 AM7/9/12
to seleniu...@googlegroups.com

Just before the line below can you add the following:

 

String htmlSource = driver.getPageSource();

System.out.println(htmlSource);

 

And show us what is printed in the console.

Hari

unread,
Jul 9, 2012, 6:53:05 AM7/9/12
to seleniu...@googlegroups.com
attached the page source
Page_Source.txt

Mark Collin

unread,
Jul 9, 2012, 6:58:41 AM7/9/12
to seleniu...@googlegroups.com

That has returned a frameset page so the reason you are getting your error is because you have not switched to the frame that holds the table, hence Selenium cannot see the table.

 

Step through your code in a debugger to work out why the frame switch isn’t happening.

Ripon Al Wasim

unread,
Jul 9, 2012, 7:04:05 AM7/9/12
to seleniu...@googlegroups.com
Hello,

Your xpath syntax seems to be not OK. You should omit the "x:" portion everywhere. Pls try by the following xpath:

xpath=//html/body/table/tbody/tr[1]/td/nobr/a[1]

Ripon Al Wasim

--

Peter Gale

unread,
Jul 9, 2012, 7:05:03 AM7/9/12
to Selenium Users
I'm not sure that helps! It's a bit of a needle in a haystack.

I can't see a single mention of an "nobr" tag in what you have provided, for example. The rest is too generic to see what element you're actually trying to point to - it could refer to almost any of the many iFrames on your page.

I'd suggest giving us all steps of the source code you use to interact with this page inlcluding the all the iframes you are switching through.


Date: Mon, 9 Jul 2012 16:23:05 +0530

Mark Collin

unread,
Jul 9, 2012, 7:08:58 AM7/9/12
to seleniu...@googlegroups.com

Not if his HTML is using namespaces he shouldn’t.  The x: part is perfectly valid if there is an x namespace configured.

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Ripon Al Wasim


Sent: 09 July 2012 12:04
To: seleniu...@googlegroups.com

Hari

unread,
Jul 9, 2012, 9:06:46 AM7/9/12
to seleniu...@googlegroups.com
Hi,
@Mark

That has returned a frameset page so the reason you are getting your error is because you have not switched to the frame that holds the table, hence Selenium cannot see the table.

Your right Mark. But

Selenium RC identifying the element and working fine. why cant the selenium webDriver ?

Regards,
Hari

Mark Collin

unread,
Jul 9, 2012, 9:29:14 AM7/9/12
to seleniu...@googlegroups.com

No idea I haven’t seen your full Selenium RC code and your full WebDriver code so that I can compare them.  The translation to WebDriver may not have gone as intended…

Hari

unread,
Jul 9, 2012, 9:47:54 AM7/9/12
to seleniu...@googlegroups.com
Hi Mark,
The below is my code for selenium RC its working fine and Web-driver also mentioned -  facing error.

Selenium RC

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class Test1 extends SeleneseTestCase {
    @Before
    public void setUp() throws Exception {
        selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://192.168.128.212:8080");
        selenium.start();
    }

    @Test
    public void test1() throws Exception {
        selenium.windowMaximize();
        selenium.open("/iwae/index.html");

        selenium.click("xpath=//x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]");
       
    }

    @After
    public void tearDown() throws Exception {
        selenium.stop();
    }
}

Selenium Webdriver:

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

public class One1 {
    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();
    @Before
    public void setUp() throws Exception {
        driver = new FirefoxDriver();
        baseUrl = "http://localhost:8080/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void testOne1() throws Exception {
        driver.get("http://192.168.128.212:8080/iwae/index.html");
        //String htmlSource = driver.getPageSource();
        //System.out.println(htmlSource);

        driver.findElement(By.xpath("//html/body/table/tbody/tr[1]/td/nobr/a[1]")).click();
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            fail(verificationErrorString);
        }
    }

    private boolean isElementPresent(By by) {
        try {
            driver.findElement(by);
            return true;
        } catch (NoSuchElementException e) {
            return false;
        }
    }
}



Regards,
Hari

Peter Gale

unread,
Jul 9, 2012, 10:01:52 AM7/9/12
to Selenium Users
Hari

Please can you check that you have sent us the right source code for the html page you are testing.

It doesn't contain any "nobr" tags that I can see, so the xpath you are trying will not work.

The Selenium RC code doesn't switch between iFrames, so I suspect that this is not the source code that your RC program gets.

I suspect that your two programs are actually pointing to two different URLs.


Date: Mon, 9 Jul 2012 19:17:54 +0530

Subject: Re: [selenium-users] Webdriver xpath is not working

Hari

unread,
Jul 9, 2012, 10:12:26 AM7/9/12
to seleniu...@googlegroups.com
Hi peter,

The source code which i have send is correc

am using http://192.168.128.212:8080/iwae/index.html that u can seeing both selenium RC and Selenium Webdriver.

Regards,
Hari

Peter Gale

unread,
Jul 9, 2012, 10:15:29 AM7/9/12
to Selenium Users
Then please show me where the "nobr" tag you are looking for is in this source code


Date: Mon, 9 Jul 2012 19:42:26 +0530

Hari

unread,
Jul 9, 2012, 10:21:59 AM7/9/12
to seleniu...@googlegroups.com
Hi Peter,
i have attached a screen shot which i have used is fire bug.


selenium.click("xpath=//x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1]");

Regards,
Hari
screenshot3.JPG

jeevan

unread,
Jul 9, 2012, 10:29:27 AM7/9/12
to seleniu...@googlegroups.com
Why can't you try:

//a/img[@alt='Collapse tree view.....']
Hope this will work...
Thanks,
Jeevan

Peter Gale

unread,
Jul 9, 2012, 10:34:08 AM7/9/12
to Selenium Users
Now show me in in the text file you attached. I can''t get this file to open in firebug and a text search of the file doesn't find any instance of "nobr".

Also, Mark mentioned the iFrames, and you said that you are switching between them, but neither of your sets of code show a switch between iFrames, not does the Firebug screenshot.


Date: Mon, 9 Jul 2012 19:51:59 +0530

Hari

unread,
Jul 9, 2012, 10:46:47 AM7/9/12
to seleniu...@googlegroups.com
Hi peter,
attached the page source

In the firebug it identifying the nobr. by clicking the tree.

In page source it not showing  showing the nobr..
Page_Source.txt

Peter Gale

unread,
Jul 9, 2012, 10:55:29 AM7/9/12
to Selenium Users
Hari

If there is no nobr tag in the page source file then it is not part of the page itself and we cannot/will not be able to see it in our local machines. Perhaps it is part of an iFrame pointing at some other web page on your network, or relies on other simiilar access which we, and webdriver, does not have.

My DOM tree looks nothing like yours when I open this page, so what you are sending us must be incomplete in some way.


Date: Mon, 9 Jul 2012 20:16:47 +0530

Mark Collin

unread,
Jul 9, 2012, 11:14:05 AM7/9/12
to seleniu...@googlegroups.com

Firebug will automatically select the frame that holds the element that you examined.  To the left of the XPath box there is a frame drop down that will let you select the other frames.  If you select the parent frameset this XPath will no longer work.

 

Firebug is no doubt giving you a correct XPath for that frame, but you still haven’t selected the frame in your selenium test.

 

I would guess that Selenium RC may be performing some implicit frame selection for a frameset (I remember intermittent errors with Selenium RC and frames from many moons ago) that WebDriver does not.  If this is the case you got lucky with the Selenium RC API (I would have also expected intermittent failures from that test), now you need to write the test properly when using the WebDriver API.

 

At the end of the day, you haven’t selected the frame, the fix is to select it.

Hari

unread,
Jul 9, 2012, 11:21:31 AM7/9/12
to seleniu...@googlegroups.com
Hi Peter/Mark

In My project many frames are integrated  in a single page.

Please find the attached frame source code for the expand tree.

@Mark Yes mark your right. Is it possible to test using the web driver ?

Regards,
Hari
Frame_Source_code.txt

Mark Collin

unread,
Jul 9, 2012, 11:37:40 AM7/9/12
to seleniu...@googlegroups.com

Yes you need to switch to the frame:

 

WebElement theFrame = driver.findElement(By.id("<ID Of Correct Frame>"));

driver.switchTo().frame(theFrame);

Hari

unread,
Jul 13, 2012, 8:24:54 AM7/13/12
to seleniu...@googlegroups.com
Hi

@ Mark

Selenium Rc : Automatically finding the Frames and giving the values.

selenium.selectFrame("tree");
selenium.click("css=img[alt=\"Expand tree \"]");

Selenium Webdriver  we have to declare the frames . It wont be automatically identify.

driver.findElement(By.cssSelector("img[alt=\"Expand tree .\"]")).click();

As per the Mark says. Working fine with the below code

WebElement theFrame = driver.findElement(By.name("tree"));
 driver.switchTo().frame(theFrame);
 driver.findElement(By.xpath("html/body/table/tbody/tr[1]/td/nobr/a[1]/img")).click();

Thank you Mark / Peter for suggestion .

Thanks & Regards,
Hari

deera sameera

unread,
Jul 6, 2014, 1:36:55 PM7/6/14
to seleniu...@googlegroups.com
Hi Hari,

Instead of absolute XPath use relative XPath.
i.e instead of   xpath=//x:html/x:body/x:table/x:tbody/x:tr[1]/x:td/x:nobr/x:a[1] this XPATH
try with "//x:td/x:a[1]"

please let me know this is working or not

Thanks and Regards
Deeraj

Ripon Al Wasim

unread,
Jul 7, 2014, 4:09:43 AM7/7/14
to seleniu...@googlegroups.com
Please ignore x:. Try with the following:

xpath=//html/body/table/tbody/tr[1]/td/nobr/a[1]


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

Harish Krishnan

unread,
Jul 7, 2014, 4:56:14 AM7/7/14
to seleniu...@googlegroups.com
Hi Ripon/Deeraj,

That issue i have faced in 13/07/2012. The issue is frames, I didnt switch to frame. After am switching its working fine.

Thanks Ripon/Deeraj for your suggestion.

Regards,
Harikrishnan




Ripon Al Wasim

unread,
Jul 7, 2014, 5:05:30 AM7/7/14
to seleniu...@googlegroups.com

Frass

unread,
Jul 8, 2014, 9:18:51 AM7/8/14
to seleniu...@googlegroups.com
That xpath is way too complex moreover I recommend not to use xpath.  I would advise you try and learn how to use css or id instead.  If you have to write more than 2 levels then you are doing too much.
Reply all
Reply to author
Forward
0 new messages