Xpath cannot select an element

Showing 1-15 of 15 messages
Xpath cannot select an element robocop 3/30/12 9:23 AM
Hi,
 
I am trying to select an element <font face="MS Sans Serif,Arial,Helvetica" color="blue" size="1">&nbsp;&nbsp;Ireland&nbsp;&nbsp;</font>

below is the html snippet and the xpath code
 
<td valign="bottom" nowrap="">
<img border="0" width="38" hspace="0" height="24" align="LEFT" alt="" src="images/cwt_rd.gif">
<table cols="1" cellspacing="0" border="0" height="3" cellpading="0" rows="1">
<a onclick="Exp(1); return false;" href="#">
<a onclick="GetEmp(1,true); return false;" href="#">
<table class="deptsel" cols="1" cellspacing="0" cellpadding="0" border="0" bgcolor="#0D9B9B" width="1" height="21" rows="1">
<tbody>
<tr>
<td nowrap="">
<a name="node1"></a>
<a class="PLAIN" onclick="Sel(1); return false;" href="#">
<font face="MS Sans Serif,Arial,Helvetica" color="white" size="1">&nbsp;&nbsp;Ireland&nbsp;&nbsp;</font>
 

xpath=//a[@name="node1"]//font
 
However I can get a far as xpath=//a[@name="node1"] but not to the font face tag. Can you help?
 
thanks
Re: Xpath cannot select an element Mike Riley 3/30/12 12:07 PM
If you have a name property use it directly instead of XPath.  It is
both faster (in execution speed) and easier (to enter) to say
"name=node1".

For selecting the font tag I am not sure how well that will work, but
you only want to use // at the start, not in the middle (AFAIK).

So try this: //a[@name="node1"]/font

Mike
Re: [selenium-users] Xpath cannot select an element Karthik 3/30/12 10:56 PM
Could you plz try with this xpath //a[@class='PLAIN']/font.

-Jay!!

--
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/-/W1LwA6-LHOIJ.
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.

Re: [selenium-users] Xpath cannot select an element robocop 4/2/12 9:34 AM
thanks guys

below worked but another snag works in FIREFOX but not IE 9.0
The line that fails is the assert for some reason-see code below



    @Test //select group
    public void testFileMnu() throws Exception {
        //testLogIn();
        selenium.click("css=ul.jd_menu> li");
        selenium.click("link=Select Group");
        selenium.waitForPageToLoad("90000");
        selenium.click("xpath=//a[@class='PLAIN']//font[contains(.,'Applegreen')]");
        Thread.sleep(6000);
        assertTrue(selenium.isElementPresent("xpath=//a[@class='PLAIN']//font[contains(.,'Applegreen') and @color='white']")); //selected
        //assertTrue(selenium.isElementPresent("xpath=//a[@class='PLAIN']//font[contains(.,'Applegreen')]")); //selected
        //xpath=//a[@class='PLAIN']//font[contains(.,'Applegreen') and @color='white']
        selenium.click("name=TB0");
        selenium.waitForPageToLoad("90000");
Re: [selenium-users] Xpath cannot select an element Hien Ngo 4/2/12 12:15 PM
Yes, your code looks correct. If that element is present the statement will return true, and throw an exception.

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/rsLf9t-BoTgJ.

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.

RE: [selenium-users] Xpath cannot select an element Mark Collin 4/2/12 1:15 PM

Is the DOM rendered in the same way in IE and FF?

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of robocop
Sent: 02 April 2012 17:34
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] Xpath cannot select an element

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/rsLf9t-BoTgJ.


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.

Re: [selenium-users] Xpath cannot select an element robocop 4/3/12 1:09 AM
Hi,

I do not understand this to be honest. If the element is present it return the correct value of true, so why does it throw an exceptions?

thanks
Re: [selenium-users] Xpath cannot select an element robocop 4/3/12 9:30 AM
Hi,

I am a newbie so would not know how to begin to answer that questions? Any pointers.
Is there any way to check that the xpath expression in IE like you can do in firefox using firefinder etc so maybe I could tweak it for IE?

thanks
RE: [selenium-users] Xpath cannot select an element Mark Collin 4/3/12 10:28 PM

Generally you need to learn about the DOM and XPath properly:

 

·         http://www.w3.org/DOM/

·         http://www.w3.org/TR/xpath-functions/

 

There are probably tools for IE that take XPath’s and see if they are valid, Google for them (I don’t use them personally so don’t know of any good ones).  The IE Dev toolbar should enable you to work out some absolute XPath’s which is good as a starter.

 

Unfortunatly the best way to understand XPath and the DOM is to read and understand the specs above (That’s how I did it).

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of robocop
Sent: 03 April 2012 17:31

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/-gJtHxM6IOwJ.


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.

Re: [selenium-users] Xpath cannot select an element robocop 4/4/12 1:23 AM
Thanks
 
I am familar with both but not sure how I would go about answering your questions?
Re: [selenium-users] Xpath cannot select an element Hien Ngo 4/4/12 2:16 PM
I have a question about the Thread.Sleep(6000); why do you need that 6 secs sleep, and what happens at that point?

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/_62-Um368JwJ.

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.

Re: [selenium-users] Xpath cannot select an element robocop 4/5/12 12:53 AM
Hi,
 
just to give the page some time to load, why?
 
thanks
RE: [selenium-users] Xpath cannot select an element Mark Collin 4/5/12 4:49 AM

Then use:

 

selenium.waitForPageToLoad("6000");

 

Never use Thread.sleep it’s putting a hard coded 6 second wait in your test for no reason and is pointless/unhelpful and the wrong way to do things.

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of robocop
Sent: 05 April 2012 08:54

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/QkkYUv1b7zUJ.


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.

Re: [selenium-users] Xpath cannot select an element Hien Ngo 4/5/12 7:18 AM
The 6 sec sleep makes your test fail intermittently
for the page loading time may be longer on some days when the network/hardware are slower, or underload.
Re: [selenium-users] Xpath cannot select an element robocop 4/5/12 7:31 AM
Hi Mark/Lerry


I agree it is pointless alright. I will give this a go and see how I get on. Have a good Easter and thanks for your help on this. No doubt I will be asking more questions :-)

thanks