![](/img/trans.png)
[英]Python Selenium issue with submit button, not working consistently
[英]Submit button is not working in Python Selenium
我沒有硒的經驗。 我嘗試了幾種方法來單擊表單內的提交按鈕,但沒有任何效果對我有用。 請幫我解決這個問題。
我發現按鈕已啟用( is_enabled()
),但未顯示( is_displayed()
)。
我一一嘗試了以下選項。 我在注釋中添加了該代碼的連續結果。
z=driver.find_element_by_xpath("//input[@name='commit']")
z.click() #It is showing error, Message: element not interactable
z.send_keys(Keys.ENTER) #It is showing error, Message: element not interactable
driver.execute_script("arguments[0].click();", z) #Shows no error, but nothing happens
z.submit() #Shows no error, but nothing happens
我試過driver.implicitly_wait(20)
但沒有運氣。 我也嘗試使用直到選項,但它給出了錯誤。
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='commit']"))).submit() #This raises TimeoutException
HTML代碼如下
input type="submit" name="commit" value="Calculate" class="btn btn-primary" autocomplete="off" data-disable-with="Calculate"
網頁鏈接是: https ://proteins.plus/ktypdbdd9c38b7-1738-45fd-a0fb-90ea86f5dd8b 我點擊“DoGSiteScorer Binding site detection”,然后點擊“DoGSiteScorer”按鈕。 現在我想點擊不起作用的“計算”按鈕。
那我該怎么做呢?
問題是這樣的:
z=driver.find_element_by_xpath("//input[@name='commit']")
在該頁面上返回 11 個元素,您不能在 11 個元素上調用click()
。
假設你想點擊紅色的計算按鈕,試試這個:
z = driver.find_element_by_xpath("(//input[@name='commit'])[2]")
z.click()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.