"findElementByXPath" possible bug

247 views
Skip to first unread message

Leonardo Galani

unread,
Mar 15, 2011, 10:29:58 AM3/15/11
to webd...@googlegroups.com
Seems a bit odd and you guys problably know.. but just for the record.

The 'FindElementByXpath' and the event click() seems not to be working... instead.. findElement(By.xpath(ARG)); is working fine

Exemple of my code

//notworking
driver.findElementByXPath("//button[@type='button']").click();

//working
driver.findElement(By.xpath("//button[@type='button']")).click();

Cheers :)

QA_manager

unread,
Mar 17, 2011, 9:01:31 AM3/17/11
to webdriver
Leonardo, please let the developers know:
- what OS and version you are using
- what version of Webdriver you are running
- what browser and version you are running

Also, please provide an HTML sample that exhibits the problem.

Eran M.

unread,
Mar 17, 2011, 9:39:21 AM3/17/11
to webd...@googlegroups.com, QA_manager
Leonardo,
Is the documentation somewhere suggesting a method like 'findElementByXPath' exists?

Otherwise, I don't see a reason why you'd expect such a method to exist. The WebDriver interface contains findElement / findElements which should be passed an explicit locator (provided by the By class). The second line of code is definitely the way to go.

Eran

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


Leonardo Galani

unread,
Mar 17, 2011, 11:20:05 AM3/17/11
to webd...@googlegroups.com
Im using the firefoxDriver that comes with Selenium 2b2.0 java + Firefox 3.6.15 + Windows XP
I already gave a sample.. i double check my code.. its a big project.. i still use findElementById... but FindElementByXpath not anymore..
If you guys can check those instrutions.. that would be great... its not the end of the world.. its just a hint ;)

Att
Leonardo Barba Galani
Arquiteto de Teste
Java, Selenium e Coca Cola (http://www.leonardobg.com.br)

Leonardo Galani

unread,
Mar 17, 2011, 11:24:38 AM3/17/11
to webd...@googlegroups.com
Oh.. i see..

So those instructions just poped out on my eclipse when i call the driver..

I know that the main funciton is the FindElement / FindElements but on that selenium version (2b02) i guess they add that instrutions to help clarify the code.. dont know why.
Just saying its bugged.. no need to tell me to look at javadocs --'
:/


Att
Leonardo Barba Galani
Arquiteto de Teste
Java, Selenium e Coca Cola
---- Original Message ----
From: "Eran M." <eran...@gmail.com>
To: webd...@googlegroups.com
Cc: "QA_manager" <no_ca...@yahoo.com>
Sent: Qui, Mar 17, 2011, 10:39 AM
Subject: Re: [webdriver] Re: "findElementByXPath" possible bug

Leonardo,
Is the documentation somewhere suggesting a method like 'findElementByXPath' exists?

Otherwise, I don't see a reason why you'd expect such a method to exist. The WebDriver interface contains findElement / findElements which should be passed an explicit locator (provided by the By class). The second line of code is definitely the way to go.

Eran

On Thu, Mar 17, 2011 at 9:01 AM, QA_manager <no_ca...@yahoo.com> wrote:

Eran M.

unread,
Mar 17, 2011, 2:50:00 PM3/17/11
to webd...@googlegroups.com, Leonardo Galani
It's likely that Eclipse suggests this API due to the type of the object - FirefoxDriver instead of just WebDriver. I was just surprised that you've found this method as it's more of an implementation detail and not advertised on tutorials / documentation (other than the javadoc).

There's no reason that a direct call to findElementByXPath would fail - if you want us to have a look at it, please attach a test case that re-creates the problem.

Cheers,
Eran 
Reply all
Reply to author
Forward
0 new messages