title | id | slug | sidebar_label | description | number | hide_table_of_contents | level | publish_date | tags | category | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Use A Page Object |
7-use-a-page-object |
/7-use-a-page-object |
Use A Page Object |
One of the biggest challenges with Selenium tests is that they can be brittle and challenging to maintain over time. This is largely due to the fact that things in the app you're testing change, breaking your tests. |
7 |
true |
2 |
2013-07-09 |
|
|
One of the biggest challenges with Selenium tests is that they can be brittle and challenging to maintain over time. This is largely due to the fact that things in the app you're testing change, breaking your tests.
But the reality of a software project is that change is a constant. So we need to account for this reality somehow in our test code in order to be successful.
Enter Page Objects.
Rather than write your test code directly against your app, you can model the behavior of your application into simple objects -- and write your tests against them instead. That way when your app changes and your tests break, you only have to update your test code in one place to fix it.
And with this approach, we not only get the benefit of controlled chaos, we also get the benefit of reusable behavior.
import DisplayTips from '@site/src/components/displayTips';
<DisplayTips languages={[ {label: 'Ruby', value: 'ruby'}, {label: 'Selenide', value: 'selenide'}, ]}/>
import DefaultAvatar from "@site/src/components/defaultAvatar";
<DefaultAvatar name="Dave Haeffner" imgSrc={"/img/authors/dave-haeffner.jpeg#author-img"} description={"the original writer of Elemental Selenium"} url={"https://github.com/tourdedave"} />
<DefaultAvatar name="Andrei Solntsev" imgSrc={"https://github.com/asolntsev.png"} description={"Contributed the Selenide code for this tip."} url={"https://github.com/asolntsev"} />