1

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()
asked Sep 24, 2021 at 17:06
2
  • 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. Commented Sep 24, 2021 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. Commented Sep 27, 2021 at 6:17

2 Answers 2

1

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"]')))
deletebutton.click()

Try below xpaths too

//input[@value='Delete']
//input[@name='action[deletecheck]']
//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)

answered Sep 26, 2021 at 13:47
1
  • Thank you! It ended up being I was not in the "active" tab Commented Sep 29, 2021 at 13:38
0

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

driver.switch_to.window(driver.window_handles[2])
answered Sep 29, 2021 at 13:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.