I
I
IlushaQA2021-03-15 17:57:29
Java
IlushaQA, 2021-03-15 17:57:29

Intellij IDEA: how to store webpage locators in a separate class?

Hello.
I recently started learning about autotests using Intellij IDEA, Java. The question is, how to organize the storage of web page locators in a separate class? For example, in order not to search in the main test class (for example: LoginPageTest.java), for example, the Email input field by the method:

driver.findElementByXPath("//*[@id=\"text\"]").sendKeys("Текст", Keys.ENTER);

And just refer to a variable that already has a path to this field, for example , where EMAILFILD is a variable with an XPath value already set (located in a separate class). I think I explained the question clearly, somehow. Thanks for the help!
EMAILFILD.sendKeys("Текст",Keys.ENTER);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Araya, 2021-03-15
@IlushaQA

internetka.in.ua/selenium-page-object
Use PageObject pattern

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question