网络代码:
<input id="black_box_name" size="30" class="ui-autocomplete-input" autocomplete="off">
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible">108 results are available, use up and down arrow keys to navigate.</span>
<input type="hidden" id="black_box_id" name="black_box_id" value="124">
我尝试将密钥发送到此输入项,但不能。我用
xpath: "//input[@id = 'black_box_id']"
系统会抱怨'Element is not currently interactable and may not be manipulated'
答案 0 :(得分:0)
您发送错误的元素。您指示的元素是隐藏的。你应该使用:
//input[@id = 'black_box_name']
顺便说一句,您已经拥有唯一ID,因此您可以通过选择ID进行优化:
id = "black_box_name"
答案 1 :(得分:0)
我使用它并且它有效:
driver.find_element_by_xpath("//*[@id='black_box_name']").send_keys(ticketTestData["inputSpecial"]["//*[@id='black_box_name']"])
x_path = "//a[text() = " + "'" + ticketTestData["inputSpecial"]["//*[@id='black_box_name']"] + "'" + "]"
logging.debug(str(datetime.datetime.now()) + " xpath " + x_path)
element = WebDriverWait(driver, medium_timeout/6).until(EC.presence_of_element_located((By.XPATH, x_path)))
element.click()