0
<li id="tb_7" class="siebui-toolbar-enable" data-cmd="#15" data-subtoolbar="N" role="menuitem" 
title="Site Map" name="SiteMap" tabindex="-1" data-tbindex="7" data-autom="find:[ot]"><span 
class="siebui-icon-tb-sitemap ToolbarButtonOn"><img src="images/icon_sitemap_1.gif"><span 
class="siebui-toolbar-text">Site Map</span></span></li>

I have tried with below code which let me in to application after successful login but getting error (at bottom):

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

username = 'abc'
password = '****'
url = 'someurl.com'

driver = webdriver.Chrome('C:/chromedriver.exe')
driver.get(url)
driver.find_element_by_name('UserName').send_keys(username)
driver.find_element_by_name('Password').send_keys(password)
driver.find_element_by_id('s_22').click()
wait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Site 
Map']"))).click()'''

Error:

File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
Manas
  • 1
  • Do you have the correct text - "Site Map" in your XPath selector ? When i copy from your code I got 2 spaces instead of 1 space. – Raymond Jan 07 '20 at 07:29
  • Can you provide the remaining of error message? – Guillaume Raymond Jan 07 '20 at 07:30
  • @Raymond full error mesage: C:\Users\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/Desktop/Others/Practise/trail.py Traceback (most recent call last): File "C:/Users/Desktop/Others/Practise/trail.py", line 15, in wait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Site Map']"))).click() File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: – Manas Jan 07 '20 at 09:37

1 Answers1

0

You were close. You can induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "li.siebui-toolbar-enable[name='SiteMap'][title='Site Map']>span.siebui-icon-tb-sitemap.ToolbarButtonOn>img[src*='images/icon_sitemap_1']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//li[@class='siebui-toolbar-enable' and @name='SiteMap'][@title='Site Map']/span[@class='siebui-icon-tb-sitemap ToolbarButtonOn']/img[contains(@src, 'images/icon_sitemap_1')]"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
  • Hi DebanjanB i have tried but no luck failing with same error:( – Manas Jan 07 '20 at 09:45
  • Error: File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: – Manas Jan 07 '20 at 09:45