-1

I am using selenium in scala to download some files automatically. I was able to login to the website but after that I was not able to move to the "Dashboard tab" by using it's div id. The error thrown is "Unable to locate element". There are two tabs named "home" and "Dashboard" in that webpage. After login, I want to move to "Dashboard" tab. I have tried everything available online but still not able to locate the tab element to click. Can someone help me out with this ? The html source that I am using is as follows

<div id="isc_35" eventproxy="DASHBOARD" role="tab" onfocus="if(event.target!=this)return;isc.EH.focusInCanvas(DASHBOARD,true);" onblur="if(window.isc)isc.EH.blurFocusCanvas(DASHBOARD,true);" tabindex="-1" style="position: absolute; left: 88px; top: 0px; width: 105px; height: 26px; z-index: 201080; box-sizing: border-box; overflow: hidden; cursor: pointer;" onscroll="return DASHBOARD.$lh()"><div id="isc_36" eventproxy="DASHBOARD" style="POSITION:relative;display:inline-block;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;vertical-align:top;VISIBILITY:inherit;Z-INDEX:201080;CURSOR:pointer;"><table width="105px" height="26px" cellspacing="0" cellpadding="0"><tbody><tr><td class="tabButtonTop" tabindex="-1" onfocus="DASHBOARD.$47()" valign="center" nowrap="true" align="center">DASHBOARD</td></tr></tbody></table></div></div>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Anand Nautiyal
  • 245
  • 2
  • 5
  • 11
  • I am using isc_35 as an id to find this tab – Anand Nautiyal Jan 15 '19 at 11:32
  • what did you try: ~ "I have tried everything available online" ~, Also what is the HTML of the HOME button? are you sure `id="isc_35"` is unique? – Moshe Slavin Jan 15 '19 at 11:39
  • @MosheSlavin - I have tried using xpath, css selector, classname etc. I have also tried using wait before clicking. I have also tried clicking with Actions. Yes, I am sure id isc_35 is unique. – Anand Nautiyal Jan 15 '19 at 11:47

1 Answers1

0

To click() on the tab with text as DASHBOARD as the element is a dynamic element you have to induce WebDriverWait for the element to be clickable and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("td.tabButtonTop[onfocus^='DASHBOARD']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//td[@class='tabButtonTop' and starts-with(@onfocus,'DASHBOARD')][contains(., 'DASHBOARD')]"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Hi @DebanjanB - I tried it out but received the following error : Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element DASHBOARD is not clickable at point (140, 70). Other element would receive the click: – Anand Nautiyal Jan 15 '19 at 12:09
  • You haven't applied _WebDriverWait_. Induce _WebDriverWait_ for **element to be clickable** and let me know the status. – undetected Selenium Jan 15 '19 at 12:13
  • I have used WebDriverWait as follows : val someElement = new WebDriverWait(driver, 100).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//td[@class='tabButtonTop' and starts-with(@onfocus,'DASHBOARD')][contains(., 'DASHBOARD')]"))).click() Is there any issue with this? – Anand Nautiyal Jan 15 '19 at 12:16
  • Checkout my updated answer and let me know the status. Ensure you use **elementToBeClickable** and nothing else. – undetected Selenium Jan 15 '19 at 12:22
  • I have tried element to be clickable as well but still I am getting the following error: Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element DASHBOARD is not clickable at point (140, 70). Other element would receive the click. – Anand Nautiyal Jan 15 '19 at 12:30
  • I have tried both cssSelector and the xpath. But, both of them gave the same error. I am not able to figure out the issue. – Anand Nautiyal Jan 15 '19 at 12:41
  • Could you please suggest what could be the issue? – Anand Nautiyal Jan 15 '19 at 12:49
  • It is a typical _waiter_ issue. Check this [discussion](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el/44916498#44916498) to solve _Element is not clickable at point_ – undetected Selenium Jan 15 '19 at 12:52
  • Thanks for your suggestions. I will look into it. – Anand Nautiyal Jan 15 '19 at 13:03