本文整理汇总了Python中IAccessibleHandler.accChild方法的典型用法代码示例。如果您正苦于以下问题:Python IAccessibleHandler.accChild方法的具体用法?Python IAccessibleHandler.accChild怎么用?Python IAccessibleHandler.accChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAccessibleHandler
的用法示例。
在下文中一共展示了IAccessibleHandler.accChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_firstChild
# 需要导入模块: import IAccessibleHandler [as 别名]
# 或者: from IAccessibleHandler import accChild [as 别名]
def _get_firstChild(self):
# accNavigate incorrectly returns nothing for NAVDIR_FIRSTCHILD and requesting one child with AccessibleChildren causes a crash.
# Therefore, we must use accChild(1).
child = IAccessibleHandler.accChild(self.IAccessibleObject, 1)
if not child:
return None
return IAccessible(IAccessibleObject=child[0], IAccessibleChildID=child[1])
示例2: locateHTMLElementByID
# 需要导入模块: import IAccessibleHandler [as 别名]
# 或者: from IAccessibleHandler import accChild [as 别名]
def locateHTMLElementByID(document,ID):
try:
element=document.getElementsByName(ID).item(0)
except COMError as e:
log.debugWarning("document.getElementsByName failed with COMError %s"%e)
element=None
if element:
return element
try:
nodeName=document.body.nodeName
except COMError as e:
log.debugWarning("document.body.nodeName failed with COMError %s"%e)
return None
if nodeName=="FRAMESET":
tag="frame"
else:
tag="iframe"
try:
frames=document.getElementsByTagName(tag)
except COMError as e:
log.debugWarning("document.getElementsByTagName failed with COMError %s"%e)
return None
for frame in frames:
pacc=IAccessibleFromHTMLNode(frame)
res=IAccessibleHandler.accChild(pacc,1)
if not res: continue
childElement=HTMLNodeFromIAccessible(res[0])
if not childElement: continue
childElement=locateHTMLElementByID(childElement.document,ID)
if not childElement: continue
return childElement
示例3: getChildHTMLNodeFromFrame
# 需要导入模块: import IAccessibleHandler [as 别名]
# 或者: from IAccessibleHandler import accChild [as 别名]
def getChildHTMLNodeFromFrame(frame):
try:
pacc=IAccessibleFromHTMLNode(frame)
except NotImplementedError:
# #1569: It's not possible to get an IAccessible from frames marked with an ARIA role of presentation.
# In this case, just skip this frame.
return
res=IAccessibleHandler.accChild(pacc,1)
if not res: return
return HTMLNodeFromIAccessible(res[0])
示例4: locateHTMLElementByID
# 需要导入模块: import IAccessibleHandler [as 别名]
# 或者: from IAccessibleHandler import accChild [as 别名]
def locateHTMLElementByID(document, ID):
try:
elements = document.getElementsByName(ID)
if elements is not None:
element = elements.item(0)
else: # probably IE 10 in standards mode (#3151)
try:
element = document.all.item(ID)
except:
element = None
except COMError as e:
log.debugWarning("document.getElementsByName failed with COMError %s" % e)
element = None
if element:
return element
try:
nodeName = document.body.nodeName
except COMError as e:
log.debugWarning("document.body.nodeName failed with COMError %s" % e)
return None
if nodeName:
nodeName = nodeName.upper()
if nodeName == "FRAMESET":
tag = "frame"
else:
tag = "iframe"
try:
frames = document.getElementsByTagName(tag)
except COMError as e:
log.debugWarning("document.getElementsByTagName failed with COMError %s" % e)
return None
if not frames: # frames can be None in IE 10
return None
for frame in frames:
try:
pacc = IAccessibleFromHTMLNode(frame)
except NotImplementedError:
# #1569: It's not possible to get an IAccessible from frames marked with an ARIA role of presentation.
# In this case, just skip this frame.
continue
res = IAccessibleHandler.accChild(pacc, 1)
if not res:
continue
childElement = HTMLNodeFromIAccessible(res[0])
if not childElement:
continue
childElement = locateHTMLElementByID(childElement.document, ID)
if not childElement:
continue
return childElement