I want to autotest my electron app and the app have already been built up so it’s a .exe file. When I try to open the file using APPIUM+Webdriver, the file can be open but I can’t find any windows handled. When I directly try to find the element on my app. It will show “can’t find such element.”
I’ve try some methods, and still can’t get into the app. When I change the app into calculator, it can find the element.
This is my code:
import unittest
from appium import webdriver
from appium.options.windows import WindowsOptions
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
import logging
logging.basicConfig(level=logging.DEBUG)
class AppTest(unittest.TestCase):
APPIUM_PORT = 4723
APPIUM_HOST = '127.0.0.1'
@classmethod
def setUpClass(cls):
caps = {
'platformName': 'Windows',
'app': r"path/to/the/app",
'appWorkingDir': r"path/to/the/workingdir"
}
options = WindowsOptions().load_capabilities(caps)
cls.driver = webdriver.Remote(f'http://{cls.APPIUM_HOST}:{cls.APPIUM_PORT}', options=options)
@classmethod
def tearDownClass(cls):
cls.driver.quit()
def test_log_in(self):
sleep(5)
try:
element = None
element = WebDriverWait(self.driver, 20).until(
EC.element_to_be_clickable((AppiumBy.XPATH, '//button[@class="yourbtnName"]')))
if element!=None:
print(element,':Element found!')
element.click()
except Exception as e:
self.fail(f"Can't found: {e}")
if __name__ == '__main__':
unittest.main()`
ray Hu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.