我必须在我正在写入的python脚本(使用硒)中的字段中提取名称输入。这里是html。有没有办法获得python/selenium中另一个元素的元素?
<div id="CF00NC000000576hm_ileinner"><a onmouseover="LookupHoverDetail.getHover('lookup005C0000003xG8C00NC000000576hm', '/005C0000003xG8C/m?retURL=%2F00QC000001DMZB8&isAjaxRequest=1&nocache=1370473054922').show();" onmouseout="LookupHoverDetail.getHover('lookup005C0000003xG8C00NC000000576hm').hide();" onfocus="LookupHoverDetail.getHover('lookup005C0000003xG8C00NC000000576hm', '/005C0000003xG8C/m?retURL=%2F00QC000001DMZB8&isAjaxRequest=1&nocache=1370473054922').show();" onblur="LookupHoverDetail.getHover('lookup005C0000003xG8C00NC000000576hm').hide();" id="lookup005C0000003xG8C00NC000000576hm" href="/005C0000003xG8C">James Brown</a></div>
的XPath是//*[@id="CF00NC000000576hm_ileinner"]
。
我最好的猜测,如何去了解这是使用:
elem1 = driver.find_element_by_xpath('//*[@id="CF00NC000000576hm_ileinner"]')
elem2 = elem1.get_attribute("innerHTML")
elem3 = elem2.get_attribute("innerHTML")
print elem3
我想在这种情况下,脚本输出“詹姆斯·布朗”。
我收到以下错误:
AttributeError: 'unicode' object has no attribute 'get_attribute'