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

1 Answer 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
  username: id=form-username
  password: id=form-password

You could then use them in a test like this:

*** Settings ***
Variables     locators.yaml

*** Test Cases ***
    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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.