Using Appium and Python for Test Automation with "contains"

  appium, automated-tests, python, windows

I’m working in test automation using Appium. This will run on a Windows machine, and we’re using python to drive Appium.
I’m able to find the main window for the application that I’m automating using:

ApplicationWindow = self.driver.find_element_by_xpath("//Pane[@ClassName='wcl_manager1']")

Then I need to search that ApplicationWindow for the button I need to press. I only know that the button will include certain text, but will have other text too. If I knew for sure what the text would be, then I could do:

MenuButton = ApplicationWindow.find_elements_by_xpath("//Button[@Name='Hub window']")

but of course I can’t.

I’ve looked through xpath documentation, and figure that the ‘contains’ part is what I need, but for the life of me I can’t get the syntax right.

I’ve tried multiple options in syntax:

find_elements_by_xpath("//Button[contains(name(), 'Hub']")
find_elements_by_xpath("//Button[contains(@Name, 'Hub']")

but none seem to be the magic bullet.

Can anyone point me to the right syntax for Python and Appium’s "contains" functionality?


Source: Windows Questions