0

I am trying to use Python Selenium to click on an HTML web element using Internet Explorer 11, can't use XPATH.

Here is the code that I am using:

from selenium import webdriver
from selenium.webdriver.support.ui import Select
import time

manage = driver.find_element_by_id("__tab_ctl00_PageBody,
_TabContainer1_Managetab")

manage.click()

And here is the HTML I'm trying to interact with:

<SPAN id=__tab_ctl00_PageBody_TabContainer1_Managetab 
class=ajax__tab_tab>Manage</SPAN>

I'm getting a NoSuchElementException.

0m3r
  • 12,286
  • 15
  • 35
  • 71

2 Answers2

0

Try to add time time.sleep(3) before manage and fix your element.

time.sleep(3)
manage = driver.find_element_by_id("__tab_ctl00_PageBody_TabContainer1_Managetab")
0m3r
  • 12,286
  • 15
  • 35
  • 71
0

The core issue is, your id locator is not correct (comma and space is the culprit). In CSS comma have it's own meaning. So your id should be

__tab_ctl00_PageBody_TabContainer1_Managetab

Screenshot: enter image description here

Please check here to see how you can check the locator if it's working correctly. Always use Explicit wait rather static wait (sleep) as shown below, by that way the script will move on to the next steps when element met the conditioin.

Imports needed:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

Your code should be (here we are waiting for the element for max of 30 seconds).

manage = WebDriverWait(driver,30).until(EC.presence_of_element_located((By.ID,'__tab_ctl00_PageBody_TabContainer1_Managetab')))
supputuri
  • 13,644
  • 2
  • 21
  • 39