Partial text search

I have an element that come up as “foo ” (attribute name) in appium inspector.

I’ve tried using self.wd.find_element_by_id(“foo ”) but getting an error in python…

“SyntaxError: Non-ASCII character ‘\xef’ in file on line 51, but no encoding declared; see for details”

Is there another partial text search I can do so that I can search for “foo” and I’ll be able to select the element?

Tried using find_elements_by_xpath("//*[contains(text(), ‘foo’)]")

But I’m getting the following error

NameError: global name ‘find_elements_by_xpath’ is not defined

Is there an alternative method I can use?

Was able to resolve this issue after adding the following to the beginning of the file…

#!/usr/bin/env python

-- coding: utf-8 --

now self.wd.find_element_by_id(“foo ”) works

Switch to Python 3 :wink:

1 Like