- // : Select current node.
- Tagname: Tagname of the particular node.
- @: Select attribute.
- Attribute: Attribute name of the node.
- Value: Value of the attribute.
from selenium.webdriver.common.by import By
Xpath=//tagname[@attribute='value']
Xpath=//input[@name='uid']
Xpath=//input[@type='text']
Xpath= //label[@id='message23']
Xpath= //input[@value='RESET']
Xpath=//*[@class='barone']
Xpath=//a[@href='http://demo.guru99.com/']
Xpath= //img[@src='//guru99.com/images/home/java.png']
Xpath=//*[contains(@type,'sub')]
Xpath=//*[contains(@name,'btn')]
Xpath=//*[contains(@id,'message')]Xpath=//*[contains(text(),'here')]
Xpath=//*[contains(@href,'guru99.com')]
Xpath=//*[@type='submit' or @name='btnReset']
Xpath=//input[@type='submit' and @name='btnLogin']
Xpath=//label[starts-with(@id,'message')]
Xpath=//td[text()='UserID']
Xpath=//*[@type='text']//following::input
Xpath=//*[@type='text']//following::input[1]
Xpath=//*[text()='Enterprise Testing']//ancestor::div
Xpath=//*[text()='Enterprise Testing']//ancestor::div[1]
Xpath=//*[@id='java_technologies']//child::li
Xpath=//*[@id='java_technologies']//child::li[1]
Xpath=//*[@type='submit']//preceding::input
Xpath=//*[@type='submit']//preceding::input[1]
xpath=//*[@type='submit']//following-sibling::input
Xpath=//*[@id='rt-feature']//parent::div
Xpath=//*[@id='rt-feature']//parent::div[1]
Xpath =//*[@type='password']//self::input
Xpath=//*[@id='rt-feature']//descendant::a
Xpath=//*[@id='rt-feature']//descendant::a[1]
-
Using
class_name
: