Selenium Xpath Cheat Sheet



Selenium Xpath Cheat Sheet

  1. Selenium Xpath Cheat Sheet
  2. Selenium Webdriver Xpath Cheat Sheet
  3. Selenium Cheat Sheet Python
  4. Selenium Cheat Sheet Pdf

CSS and XPath can both be used to denote locations in an XML document. These 2 syntaxes help guide your Selenium tests and allow automation to follow your well thought out test strategy. CSS is native to all browsers and specifically built for rendering in browsers, while XPath can give your Selenium test an exactness that is sometimes lacking in CSS. We put together a few tables to help translate XPath to CSS and vice versa. For browser testing, this translation can be especially effective for designers, developers and testers working together during the development and testing phase.

General:
What It DoesXPathCSS
All HTML/htmlhtml
Body of Page/html/bodybody
Element box absolute reference/body/…/boxbody > … > .box
Any element matching boxboxbox
Any element in the document**
ID of an element[@id='green-background']#green-background
Class of an element[@class='Box'].box
Any element matching title that is a descendant of boxbox//titlebox > title
Any element matching title that is a child of boxbox/ title.box .title
Any element matching title immediately preceded by box elementbox/following-sibling::*[1]/self::title.box + .title
Image element//imgimg
Selenium xpath cheat sheet excel

Selenium Xpath Cheat Sheet

Predicates
What It DoesXPathCSS
Selects first child element/box/title[1].box .title:first-child
Selects the last child element/box/title[last()].box .title:last-child
Selects the second to last child element/box/title[last()-1].box .title:nth-last-child(2)

Selenium Webdriver Xpath Cheat Sheet

See Also

Selenium Best Practices
Selenium and Ruby

Selenium Cheat Sheet Python

Cheat

Selenium Cheat Sheet Pdf

Java selenium commands cheat sheet - Selenium Blog says: May 11, 2018 at 11:32 am Previous: Previous post: Execute Python Selenium tests in Selenium GridNext: Next post: Python selenium commands cheat sheet. Selenium Selenium WebDriver with Python Cheat Sheet. This blog article lists Python Selenium WebDriver commands which are helpful to automate Web Application Testing.