我正在自动化一个web应用程序。我必须单击一个文本框,然后从单击文本框后显示的列表框中选择一个值。请看所附图片
这是我写的代码:
childObjOfParentDiv= getChildrenObject(eval(parentObj))
selectOptionFromList(childObjOfParentDiv[1],"JACK")
@staticmethod
def getChildrenObject(parentObject):
children = []
try:
parentObject = Synchronization.waitForObject(parentObject)
for child in object.children(parentObject):
children.append(child)
except Exception as err:
Logger.error("exception message: %s, exception args: %s", err.message, err.args)
finally:
return children
@staticmethod
def selectOptionFromList(parentObject, optionValue, propertyName = 'value', exactMatch = False):
children = Utilities.getChildrenObject(parentObject)
for child in children:
try:
propertyValue = Utilities.getObjectPropertyValue(child, propertyName).strip()
if exactMatch and (optionValue == propertyValue):
Wrapper.mouseClick(child)
Synchronization.wait(StaticWait.minWaitInSeconds)
break
elif optionValue in propertyValue:
Wrapper.mouseClick(child)
Synchronization.wait(StaticWait.minWaitInSeconds)
break
except Exception as err:
Logger.error("exception message: %s, exception args: %s", err.message, err.args)
但是datalist中的选项没有被选中,datalist显示为空
下面是一个例子。你知道吗
请注意,输入要选择的datalist条目文本是必需的,因为至少Firefox似乎没有报告datalist选项元素的有效屏幕坐标,并且调用option元素的click方法似乎没有效果。你知道吗
在输入元素中输入条目文本后,数据列表将向下过滤到该条目,然后可以通过相对于输入元素的鼠标单击或按键来选择条目。你知道吗
相关问题 更多 >
编程相关推荐