0

It is the line of code that i am using to find the element using chrome web driver and python

This the error that is thrown everytime when i try to run the code

These are the buttons on the header bar and I am trying that my code should click the html button

This is the html code for the efforts button which i am trying to target using selenium so that it can click here but it always says no such element found

I have even created a seperate function to again and again find the element and sleep for 5 sec after every successful attempt until it has clicked on the element but still no luck it runs on forever without ever finding the element

This is where i am calling the function explained in the 5th picture. Here driver is chromedriver and it keeps on repeating for 10 times with 5 sec intervals but still no luck and i am continuously watching the chrome window where driver do all the work and the page has loaded but even after it is loaded it is still not working.

It is the beginning of entire html code from inspect element in case needed by someone

This is the remaining HTML code with EFFORTS area selected in case needed

I have even tried using shadow root but that is also not working and i am also not sure that this is a case of shadow root as i have not seen shadow root specified in html when i checked the html code.

Dev Chahal
  • 23
  • 5
  • Yowza, what are those links and photos? You should just write them as code into your question. – Ekrem Dinçel Apr 12 '20 at 15:06
  • 1
    Sorry about that i have never asked a question before it showed an option to upload photos i thought it will show both images and there details. I will remember it next time – Dev Chahal Apr 12 '20 at 15:31
  • Okay, you can look at this link for learning how to format posts: https://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks – Ekrem Dinçel Apr 13 '20 at 19:51

2 Answers2

1

The element you are trying to locate is under iframe with class iframeStyle. First switch to that iframe to access the Efforts link.

enter image description here

mkhurmi
  • 786
  • 4
  • 12
  • Thanks man that helped it was the problem with iframe Tanks for your help – Dev Chahal Apr 13 '20 at 07:00
  • One more Question can u help how do i change to the specific iframe as it does not have a id or name and i am not able to search it using xpath it says it is not a valid xpath expression element=driver.find_element_by_xpath("//iframe[@class='iframeStyle'") I used this line to find it using xpath to switch to this frame – Dev Chahal Apr 13 '20 at 07:48
  • Try this : 'driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))' – mkhurmi Apr 13 '20 at 16:53
  • This link might be useful for you : [https://stackoverflow.com/questions/7534622/select-iframe-using-python-selenium](https://stackoverflow.com/questions/7534622/select-iframe-using-python-selenium) – mkhurmi Apr 13 '20 at 16:55
0

try below xpath using xpath contains to resolve your issue:

 WebDriverWait(driver, 30).until(
                EC.element_to_be_clickable((By.XPATH, "//a[contains(text(), 'EFFORTS')]")))

or

WebDriverWait(driver, 30).until(
            EC.element_to_be_clickable((By.ID, "tmsMobileId")))

Note : please add below imports to your solution

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

If you still facing no such element exception then please check if your element is present under iframe. If so then you need to switch iframe before handling EFFORTS anchor tag

SeleniumUser
  • 4,065
  • 2
  • 7
  • 30
  • You posted similar answers two times. You should edit your answer instead. – Ekrem Dinçel Apr 12 '20 at 15:02
  • Yes mistakenly done actually. I will remove old one – SeleniumUser Apr 12 '20 at 15:03
  • Traceback (most recent call last): File "E:/work/wipro/work/pns-database/practice/attendance_filler/fill_attendance.py", line 62, in WebDriverWait(driver, 30).until( EC.element_to_be_clickable((By.XPATH, "//a[contains(text(), 'EFFORTS')]"))) File "E:\work\python\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: This is the error it shows when i try ur changes Still not working – Dev Chahal Apr 12 '20 at 15:30
  • selenium.common.exceptions.TimeoutException: Message: This is the error as i was not able to upload a pic to show the error i copied the entire error hope that clarifies The code is still not working – Dev Chahal Apr 12 '20 at 15:32
  • As i mentioned in the notes section have you verified if your element present in the iframe? – SeleniumUser Apr 12 '20 at 16:51
  • would you kind enough to [accept](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) answer if your issue is resolved – SeleniumUser Apr 16 '20 at 16:41