문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top