robotframework-appiumlibrary icon indicating copy to clipboard operation
robotframework-appiumlibrary copied to clipboard

page_should_contain_text() and page_should_not_contain_text() unreliable

Open yahman72 opened this issue 7 years ago • 0 comments

Just noticed this when comparing old (v1.3.x) code the to the latest one.

This code is a bit unreliable:

        if not self._is_text_present(text):
            self.log_source(loglevel)

because the logs might contain wrong page source.

What the above does is

  1. self._is_text_present(text) gets page source and checks whether the text is present.
  2. If not, then the self.log_source(loglevel) gets the page source again and logs it

If the page source is not the same in steps 1 & 2 we'll log wrong page source.

FIX: Get the page source only once and use it for the logs in case of errors (like it was done in the v1.3.x)

yahman72 avatar Jan 15 '18 14:01 yahman72