Search code examples
pythonandroidmobileautomated-testsappium

Cant automate webview in hybrid appium test in python


I am trying to make a automatic test for the WEBVIEW part of my app. I can switch to the WEBVIEW context, but I cannot find the UI elements.

self.driver.find_element_by_accessibility_id('StartTrainingButton').click()
time.sleep(5)

self.driver.switch_to.context('WEBVIEW')
time.sleep(10)

a = self.driver.find_element_by_id('first_name').value_of_css_property(".form-control")
print(a)
time.sleep(5)
self.driver.find_element(id, "wp-submit").click()

Here is the data of the textbox first_name:

input class="form-control" type="text" name="first_name" id="first_name" value="" placeholder="Vorname" required=""

Solution

  • So for you guys who might have the same problem, this is how it works for my hybrid app:

        self.driver.find_element_by_accessibility_id('StartTrainingButton').click()
        time.sleep(5)
    
        self.driver.switch_to.context('WEBVIEW')
        time.sleep(3)
    
        self.driver.find_element_by_id('first_name').send_keys('Test_first')
        self.driver.find_element_by_id('last_name').send_keys('Test_last')
    

    As you see, easier than i thought...