我提出了一个关于selenium web测试的问题。因为所有元素都需要自己的xpath或css选择器才能由selenium webdriver执行操作。 我尝试过使用python枚举并创建类似
file: elementEnum.py
from enum import Enum
class PageA(Enum):
pElementA = '//div[{}]'
pElementB = '//a[.="{}"]'
pElementC = '//div[@class={}]'
class PageB(Enum):
pElementA = '//button[.="{}""]'
pElementB = '//table/tr[{}]/td[{}]'
但事实证明,我在python格式函数中构建字符串需要很多时间,但它没有看到pythonoic。在
^{pr2}$对我来说,列出所有对应元素及其定位器的最佳方法是什么。在
你可以用
在位于的元素的EC可见性定位元素
http://selenium-python.readthedocs.io/waits.html
样本代码:
你也可以
^{pr2}$这可以传递元组来定位元素吗
相关问题 更多 >
编程相关推荐