Xpath and CSS selectors

1,583 views
Skip to first unread message

rdekleij...@gmail.com

unread,
Nov 29, 2010, 5:14:51 PM11/29/10
to Selenium Users
hi,

what is the difference between xpath and CSS selectors?
In which case should I use xpath as I normally use CSS?

which one is better?


Thanks,
Roy

Brian Kitchener

unread,
Nov 29, 2010, 10:12:14 PM11/29/10
to Selenium Users
From what I understand CSS is faster, so use it if you can. However,
xpath tends to allow more precision finding an element on the page.

On Nov 29, 3:14 pm, "roydekle...@orange.nl"

Yuping Zhong

unread,
Nov 29, 2010, 10:15:14 PM11/29/10
to seleniu...@googlegroups.com
Compare the performance, CSS is better. Specially when you apply the test code in IE.

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


rdekleij...@gmail.com

unread,
Nov 30, 2010, 4:35:21 AM11/30/10
to Selenium Users
ok, thanks for you reply..

In which situations do I have to use XPath? when is it usefull ?

Maybe someone can give me some example on that?


Much appreciated,
Roy de Kleijn



On 30 nov, 04:15, Yuping Zhong <littlezhong...@gmail.com> wrote:
> Compare the performance, CSS is better. Specially when you apply the test
> code in IE.
>
> On Tue, Nov 30, 2010 at 11:12 AM, Brian Kitchener <kitchener.br...@gmail.com
>
> > wrote:
> > From what I understand CSS is faster, so use it if you can.  However,
> > xpath tends to allow more precision finding an element on the page.
>
> > On Nov 29, 3:14 pm, "roydekle...@orange.nl"
> > <rdekleijnaspi...@gmail.com> wrote:
> > > hi,
>
> > > what is the difference between xpath and CSS selectors?
> > > In which case should I use xpath as I normally use CSS?
>
> > > which one is better?
>
> > > Thanks,
> > > Roy
>
> > --
> > 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<selenium-users%2Bunsu...@googlegroups.com>
> > .

Narendra Lahoti

unread,
Dec 1, 2010, 7:37:22 AM12/1/10
to Selenium Users
CSS selector allow only single direction(Parent to child element)
traverse ,but xpath does allow bidirectional traverse.

so based on need xpath might be the only option

-Narendra

On Nov 30, 2:35 pm, "roydekle...@orange.nl"

Niraj Kumar

unread,
Dec 1, 2010, 9:01:27 AM12/1/10
to seleniu...@googlegroups.com
Go through this post . This might help you identify the scenario for CSS and xpath

http://automationtricks.blogspot.com/search/label/CSS%20and%20Selenium


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.




--
Thanks & Regard,
Niraj Kumar

Reply all
Reply to author
Forward
0 new messages