0

What is best practice when writing acceptance tests for a form l without knowing the exact layout of the HTML file? Would it be for example to test that the page contains, let's say an element with div[@id=form_field_name], and "force" the developer to use that id? Is there a better way to approach this? I'm using Robot Framework

Bryan Oakley
25.5k5 gold badges67 silver badges90 bronze badges
asked Oct 26, 2016 at 3:54

1 Answer 1

1

The best practice is to work with the developer to insure as much as possible that all of the elements you need to access during testing have unique ids. Finding elements on the page by id is by far the most efficient and reliable method of accessing elements.

Since you are using robot, another thing you might do is create a data structure to contain the locators for elements so that you can reference them within the test via a human readable name.

For example, you could create a yaml file that contains all of your locators in an easy-to-edit format:

# locators.yaml
locators:
 username: id=form-username
 password: id=form-password

You could then use them in a test like this:

*** Settings ***
Variables locators.yaml
*** Test Cases ***
Example
 ...
 input text ${locators.username} imontoya
 input text ${locators.password} YouKilledMyFather

The advantage to this approach is that the developer isn't required to make human-friendly names for the ids, which might not be possible with the framework they are using. Plus, if the locators change (and they quite often will), you only have to update this one file rather than updating every test case that uses a given locator.

answered Oct 26, 2016 at 11:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.