【发布时间】:2021-07-09 22:57:09
【问题描述】:
我正在使用带有 python 的机器人框架,尝试使用 appium+Winium.Desktop.Driver 进行桌面自动化。
我能够启动应用程序并创建驱动程序会话,但是我无法在其他 python 类中使用相同的驱动程序会话来访问应用程序上的元素。
当我尝试对应用程序执行操作时出现错误。 AttributeError: 'NoneType' object has no attribute 'find_element_by_name'
我的应用程序是 Windows 桌面应用程序(Windows 10)
我在这里遗漏了什么吗?请帮忙。 任何人都可以提出最佳可行的解决方案。
文件:-launchapp.robot
*** Settings ***
Library ../Resources/DriverFactory.py
Library ../Resources/SignOnPage.py
*** Test Cases ***
Check whether application is running if not launch the application
driverfactory
click on signon button
*** Keywords ***
文件:- DriverFactory.py
from appium import webdriver
import time
from robot.api.deco import keyword
class DriverFactory:
instance = None
@staticmethod
@keyword
def driverfactory():
instance = webdriver.Remote(command_executor="http://localhost:9999",
desired_capabilities={"app": "AbsoultePath_of_My_APP.exe", "args": '-port 345'})
time.sleep(40)
return instance
文件:- SignonPage.py
from robot.api.deco import keyword
from DriverFactory import DriverFactory
class SignOnPage:
@staticmethod
@keyword
def click_on_signon_button():
DriverFactory.instance.find_element_by_name("Sign On").click()
【问题讨论】:
标签: python python-3.x robotframework