我正在尝试在包含默认字符串的文本字段中输入一个金额。
该字段的 HTML:
<div class="InputGroup">
<span class="InputGroup-context">$</span>
<input autocomplete="off" class="Input InputGroup-input" id="amount" name="amount" type="text" maxlength="12" value="0.00">
</div>
当尝试向字段输入文本时,它不会替换默认文本,而是将其附加到该字段中。
我曾尝试使用amount.clear()(数量是我调用的元素),但在运行它并发送密钥后,它会引发以下异常:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
正如您将在我当前的代码中看到的那样,我还尝试双击默认文本,但这无济于事。
这是我目前的代码:
ActionChains(driver).move_to_element(amount).click(amount).click(amount).perform()
amount.send_keys(Keys.BACKSPACE)
amount.send_keys('100')
当我期望 100 时,这会导致输入字段为 0.00100。
互换的青春
相关分类