我正在测试windows应用程序
第一步是启动应用程序启动器并选择数据库。下一步是直接登录到应用程序,而不是在第一步之后关闭的启动器中。因此,我需要在一个测试中将会话(在我的代码中它是处理程序)从启动器切换到应用程序。如何正确地做
我的经纪人:
class Handlers:
def launcherHandler(self):
desired_caps = {}
desired_caps["app"] = Data.programu
launcherDriver = webdriver.Remote(
command_executor='http://127.0.0.1:4723',
desired_capabilities=desired_caps)
return launcherDriver
def applicationHandler(self):
desired_caps = {}
desired_caps["app"] = "Root"
self.driver = webdriver.Remote(
command_executor='http://127.0.0.1:4723',
desired_capabilities=desired_caps)
WebDriverWait(self.driver, 50).until(EC.element_to_be_clickable((By.NAME, 'App')))
AppWindow = self.driver.find_element_by_name('App')
AppTopLevelWindowHandle = AppWindow.get_attribute("NativeWindowHandle")
AppTopLevelWindowHandle = hex(int(AppTopLevelWindowHandle))
appCapabilities = {}
appCapabilities["appTopLevelWindow"] = AppTopLevelWindowHandle
appSession = webdriver.Remote(
command_executor='http://127.0.0.1:4723', desired_capabilities=appCapabilities)
appSession.maximize_window()
return appSession
我的测试方法:
class Tests:
def myTest(self, handler1, handler2, name):
Methods.wait(self, handler1, Locators.appWindowName)
Methods.elementIdClick(self, handler1, Locators.baseComboBoxId)
Methods.elementNameClick(self, handler1, Locators.newPodmiotName)
Methods.elementIdClick(self, handler1, Locators.simpleRadioButtonId)
Methods.textBoxIdSendKeys(self, handler1, Locators.nameTextBoxId, name)
Methods.elementIdClick(self, handler1, Locators.runButtonId)
Methods.elementIdClick(self, handler1, Locators.runButtonId)
Methods.wait(self, handler2, Locators.appWindowName)
最后是我的测试:
class test(unittest.TestCase):
@classmethod
def setUpClass(self):
self.handler1 = Handlers.launcherHandler(self)
self.handler2 = Handlers.applicationHandler(self)
def test(self):
Tests.myTest(self, self.handler1, self.handler2, Data.name)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(test)
关闭启动器(handler1)后,测试不会等待程序打开(handler2)。我知道我可能不应该在课堂上给handler2打电话,但我没有其他想法。如何修复它
你能帮我吗
目前没有回答
相关问题 更多 >
编程相关推荐