New answers tagged

1

you can iterate through searchHindts elements and return the element that contains the text you want. IF the returned element is empty or null you can fail the tests. This would be a better approach if you are conserned about the order eg: a= $$("something") (for i of a){ if(a.getText===assertion){ return a; } } here the function returns undefined or the ...


1

You can further break down your components into other components, by passing the baseLocator as you do with the components. MainPage { baseLocator = driver.find("body") ] MainPage() { BigForm = BigForm(baseLocator.find("#myBigForm")) } } BigForm { BigForm(baseLocator) { Section1 = Section1(baseLocator.find(#section1) Section2 = ...


1

Page object without good abstract layer is trash which breaking a lot of programing rules like single responsibility and etc. Better to develop an abstract layer with components and then reuse this component in your page classes. You can create shared components and specific components, this similar approach in web development, for example, when you using ...


3

I like to take it one step further and also make abstractions for test-data like a user. login(user) { this.setEmail(user.email); this.setPassword(user.password); this.submit(); } This userObject could check if it exists, setup itself. I dont like to hardcode things like passwords in the test. Follow clean code princibles when splitting ...


4

As with any piece of software, you can consider a few heuristics when deciding abstractions: 1 - On a higher-level abstraction, Single Responsibility Principle: A component (method, class, module) should serve a single actor. Meaning that a component should change for a single reason. E.g., if you have a HomePage object that has loginand goToAboutPage, ...


1

It is totally depends on individual how he is writing framework. For me, I recommend to break a big ui task in to small steps as well and covert them in small function. As these small function can be reused/call whenever required and play a vital role in negative test cases and it would be play a good role If you need to test a feature so you can ...


3

There aren't any hard rules when it comes to writing Page Object Model or any test Framework. The key is to identify the approach that makes it reusable, easy to understand , and less maintenance effort. Some of the procedures i follow are: Should i bother writing a wrapper function like login? Why to bother having login function if it is not used in ...


6

I wouldn't say the PoM pattern is intended to model a behavior. Rather a user interface. Tests are intended to model behavior. If you have your object less abstract then you can assert the results more precisely. Having just a login method wouldn't let you assert the things which happens inside login. We'll, technically you'll be able to but asserting ...


3

The choice of such design lies mainly on the product under test, tool, and the language you use. My personal preference is to: Add it in Page objects if it's being reused many times If it's just for 1 test case then, have it in the test suite itself. The reason for following the practice of not having assertions in page objects was to promote easy ...


2

In my experience, it is best to put the waits in the Page Objects. The purpose of the waits are to wait for an element to be displayed or to have the page finished loading, etc (depending on the wait you are using). Using POM, all your elements are in the page object and you write methods that utilize those elements also in the page object. Given this, you ...


2

Try to change @FindBy(xpath = "a[@class='HeaderMenu-link no-underline mr-3']") private WebElement signInBtn; to @FindBy(xpath = "//a[@class='HeaderMenu-link no-underline mr-3']") private WebElement signInBtn; Two slashes are missing before a.


1

I think you are forgeting to init the Elements and try to click on an element that is still null. Add something like this to the constructor of the page PageFactory.initElements(driver, this); Something like: public MainPage(WebDriver driver){ this.driver = driver; PageFactory.initElements(driver, this); } Look at this question for an example: ...


1

Technology wise it depends on who might use it, we have developed test suites with protractor but they are rule out because there are no many automation tester who are adept with javascript. Go with the technology you or your team feel more comfortable with. edit: misread the question.


Top 50 recent answers are included