使用xpath获取元素 document.evaluate

select_js = """

function getElementByXpath(path) {

return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;

}

ele = getElementByXpath(arguments[0]);

ele.readOnly = false;

ele.value = arguments[1];

"""

driver.execute_script(select_js, "//select[@id='Agency']/following-sibling::div//input",'推荐机构会员20190715')

(0)

相关推荐