0

When I am running my tests with the application closed to start, it can't find any of the elements I'm asserting. When I run it with the windows application open already, it finds the elements. Any idea what I'm doing wrong? As you can see from the commented rows, I've been trying waits, maximizing the window, searching by different methods (XPATH instead of accessibility_ID)

from appium import webdriver
from appium.options.windows import WindowsOptions
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.wait import WebDriverWait
import unittest

class eToolsTests(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        classic_options = WindowsOptions()
        classic_options.app = "C:\\eTools\\eTools.exe"
        self.driver = webdriver.Remote(
            command_executor='http://127.0.0.1:4723/wd/hub',
            options=classic_options)
        # self.wait = WebDriverWait(self.driver, 15, 1)
        # self.driver.maximize_window()

    @classmethod
    def tearDownClass(self):
        self.driver.quit()

    def test_eTools_version(self):
        # el = self.wait.until(lambda x: x.find_element(AppiumBy.ACCESSIBILITY_ID, 'TitleBar'))
        el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='TitleBar')
        # el = titleBarText = self.driver.find_element(by=AppiumBy.XPATH, value='/Window/TitleBar')
        titleBarText = el.get_attribute('Value.Value')
        self.assertEqual(titleBarText, "eTools v4.0.2.9", msg="version was not v4.2.0.9")

    def test_TestingMode(self):
        el = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='TitleBar')
        # el = titleBarText = self.driver.find_element(by=AppiumBy.XPATH, value='/Window/TitleBar')
        titleBarText = el.get_attribute('Value.Value')
        self.assertTrue("[Testing Mode" in titleBarText, "The application is not in Testing Mode")

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(eToolsTests)
    unittest.TextTestRunner(verbosity=2).run(suite)
Don Ross
  • 1
  • 1

0 Answers0