-
Notifications
You must be signed in to change notification settings - Fork 0
How to create locator
Roman Pobotin edited this page Jun 8, 2018
·
4 revisions
For finding locator better use Chrome browser
- Go to web pages from where you want to get a locator (Google )
- Find needed locator (search field for example) and right click on it and click "Inspect element"
- Selected locator will be found automatically in DOM
- Right-click on locator in DOM and click Copy -> Copy XPath
You can copy any type of locator, but XPath is easier to read
- Go to project in PyCharm (project -> framework -> locators.py)
- Create new class for your new page (or currently created page)
class GoogleSearchLocators:
- Create new variable in class with copied XPath from site
search_field = (By.XPATH,"//*[@id='lst-ib']")
, where search_field is a name of your variable; By.XPATH type of locator to search; "//*[@id='lst-ib']" copied locator path from site.
You have been created you first locator in this framework.
Go to the How to create test method page to understand how to use your locators.