如何通过SeleniumWebDriver和Python在没有唯一标识符的文本框中单击
如何通过SeleniumWebDriver和Python在没有唯一标识符的文本框中单击,python,selenium,selenium-webdriver,webdriver,webdriverwait,Python,Selenium,Selenium Webdriver,Webdriver,Webdriverwait,= = 根据您共享的HTML,找到与{userid}字段对应的文本框,您需要引导WebDriverWait使元素可单击,您可以使用以下解决方案: XPATH: WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel']/div[contains(@data-bind, 'UriParameters')]/div//following::input[2]"))).cl
=
=
根据您共享的HTML,找到与{userid}
字段对应的文本框,您需要引导WebDriverWait使元素可单击,您可以使用以下解决方案:
:XPATH
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel']/div[contains(@data-bind, 'UriParameters')]/div//following::input[2]"))).click() #or WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='panel']/div[contains(@data-bind, 'UriParameters')]/div//following::input[2]"))).send_keys("Ice")
userid
字段并执行你的任务吗?@Ice你能用你当前的代码试用更新问题以找到文本框和异常以供进一步分析吗?我找到了!我对你的代码做了一个简单的修改,从userID=WebDriverWait(driver,20).到(EC.element\u to\u be\u clickable((By.XPATH,//div[@class='panel']]/div[contains(@data bind,'UriParameters')]/div//contains(@data bind,'UriParameters')]]/following::input[2]”)到driver/div//following::input[2]”。单击()
非常感谢!完成!再次感谢!