nhsuk / ui-test-core

Python package which helps with writing UI tests by providing a wrapper around Selenium and other useful functions
MIT License
12 stars 6 forks source link

[BUG] Using the 'for_element_to_have_attribute' method results in an exception #40

Closed abennell closed 1 year ago

abennell commented 1 year ago

Describe the bug If you use the 'for_element_to_have_attribute' method in waiter.py in your tests, and the element with the expected attribute and value is found in the DOM, an exception will be thrown. This exception occurs when the logger attempts to write the log message on line 78. This is because it's trying to pass in more args to the string formattr than you have placeholders in the string; the final placeholder being $s rather than %s

To Reproduce Steps to reproduce the behavior:

  1. Implement the above method in your tests, referencing an element which contains the expected attribute and value
  2. Run your tests

Code snippet

[self.logger.info](http://self.logger.info/)("Waiting for %s to be have attribute %s=$s", page_element, attribute_name,
                         expected_attribute_value)

Expected behavior The log message should be generated correctly, accepting all 3 arguments passed in on line 78.

Additional context N/A