Skip to content

Convert int/float inputs to strings before typing text

Compare
Choose a tag to compare
@mdmintz mdmintz released this 22 Sep 15:20
· 4213 commits to master since this release
57faf6f

Convert int/float inputs to strings before typing text

  • Convert integer inputs to strings before typing text
  • Also update the cffi requirement to cffi==1.14.3

The fix for this is simple:

if type(text) is int or type(text) is float:
    text = str(text)

This conversion is necessary to prevent errors from occurring in:

if not text.endswith('\n'):
    element.send_keys(text)
else:
    element.send_keys(text[:-1])
    element.send_keys(Keys.RETURN)

Most text-typing methods already fixed this. Now they all fix it.

  • Fixed methods:
self.add_text(selector, text)
self.send_keys(selector, text)  # Same as self.add_text()