I am attempting to click a delete button but Selenium does not locate it even though a save button next to it is completely intractable. The only difference is the delete button has this in the html

<input type="submit" name="action[deletecheck]" class="SPSubmitRequest disabledsubmit" formmethod="get" value="Delete">

anyone run into this issue?

The selenium error is "no such element: Unable to locate element

Python code

driver.find_element_by_xpath('//*[@class="SPSubmitRequest disabledsubmit"]').click()
  • 2
    Please add your Python code and the HTML of the button. The more information we have, the easier it will be to help you.
    – pavelsaman
    Sep 24 '21 at 18:48
  • Have you verified the xpath you're using is correct and is able to identify with element node? You can use browser console ($x(your_xpath)) to check this or use any plugin like SelectorsHub to achieve this. Sep 27 '21 at 6:17

May be you need apply Explicit waits and try different xpath.

Apply Wait like below and try:

# Imports Required
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

wait = WebDriverWait(driver,30)

deletebutton = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@class="SPSubmitRequest disabledsubmit"]')))

Try below xpaths too

//input[@name='action[deletecheck]' and @value='Delete']

Note that the xpath should highlight the Element in the DOM and it should be unique (1/1)

  • Thank you! It ended up being I was not in the "active" tab Sep 29 '21 at 13:38

Well the answer was about as simple as they come... I wasn't in the active tab.The following code fixed it instantly


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.