Hi, I just started using appium and I decided to make small scripts that make and send photos on Snapchat.
I am running it locally on Xiaomi mi5.
My code crashes 50% of the time, and always from NoSuchElementException.
The weird thing is the code throws an exception when I try to click an element, but I can see that on my phone element is clicked.
I am sure that selectors are valid.
Simple version of my code
snap = Device()
snap.make_photo() <- // this throws NoSuchElementException
snap.press_send_button()
Versions
App version: 1.21.0
Electron: 7.2.4
Node.js: 12.8.1
Os: Ubuntu 21.04
Full source code
class Device:
def __init__(self):
desired_caps = dict(
platformName="Android",
automationName="uiautomator2",
appPackage="com.snapchat.android",
appActivity="LandingPageActivity",
noReset=True,
)
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
self.driver.implicitly_wait(15)
def _rselect(self, r_id):
return self.driver.find_element_by_xpath(f'//*[@resource-id="{r_id}"]')
def _rclick(self, r_id):
self._rselect(r_id).click()
def make_photo(self):
self._rclick("com.snapchat.android:id/camera_capture_button")
def press_send_button(self):
self._rclick("com.snapchat.android:id/send_btn_layout")