0

I am new to Selenium and HTML. I am trying to click on one of the navigation menu options.

Here is the screenshot:

enter image description here

And here is the code I get when I inspect the element:

<A onclick="click_shelltab2('reports','tab_reports')" href="https://abhow.onesite.realpage.com/100/multishell/shell.htm?c=111101011111000001000001101000010011010010000000100010000000000101001000000100100000000010,176819146,USER&amp;u=100,111111111011100#"><SPAN class="rp-global-nav-menu-item-label-icon fa fa-calendar-check-o"></SPAN><SPAN class=rp-global-nav-menu-item-label-text>Scheduled Events</SPAN></A>
<SPAN class="rp-global-nav-menu-item-label-icon fa fa-calendar-check-o"></SPAN>
<SPAN class=rp-global-nav-menu-item-label-text>Scheduled Events</SPAN>
/a>

How do I get it work?

I tried using following:

wait2.until(lambda driver: driver.find_element_by_xpath("//a[@id='tab_reports']")).click()

and

wait2.until(lambda driver: driver.find_element_by_xpath("//a[@text='Scheduled Events']")).click()

and

wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//span[text()='Scheduled Events']"))).click()

Update:

when I use Xpath = `//*[@id="tab_reports"]/span/a'

it gives this error:

ElementClickInterceptedException: element click intercepted: Element <a class="" href="#" onclick="doActionSupportCrossBrowser('Scheduled Events', tab_reports_center);">...</a> is not clickable at point (267, 152). Other element would receive the click: <iframe id="ifrmShell" name="ifrmShell" style="border:none;display:inline;border-left:1px solid #000000;height:100%;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;width:99.95%;" frameborder="0" scrolling="auto" src="/shell_cb/nav/iframe_init.htm"></iframe> (Session info: chrome=81.0.4044.129)

Please help.

Thanks in advance.

Learner27
  • 391
  • 1
  • 4
  • 13

2 Answers2

0

I see that you've tried several xpaths. Ask the browser what's the right xpath.

Possible potential issues:

  • timeout, set implicit wait: driver.implicitly_wait(10)
  • element is not visible and it's not clickable -> scroll the page accordingly
RafalS
  • 5,834
  • 1
  • 20
  • 25
  • Hi found the `Xpath wait2.until(lambda driver: driver.find_element_by_xpath('//*[@id="tab_reports"]/span/a/span[2]')).click()` . It gives the error - element not intractable – Learner27 May 05 '20 at 18:59
  • https://www.reddit.com/r/learnpython/comments/c87tot/selenium_and_elementnotinteractableexception_error/ – RafalS May 05 '20 at 19:30
0

Induce WebDriverWait() and element_to_be_clickable() and following xpath

link=WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//a[.//span[text()='Scheduled Events']]")))
link.click()

If you get the same error the use Java script executor to click.

link=WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//a[.//span[text()='Scheduled Events']]")))
driver.execute_script("arguments[0].click();", link)
KunduK
  • 32,888
  • 5
  • 17
  • 41