0

I'm working on automating the scheduling of some reports. I've gotten as far as opening the report, but Selenium can't locate the 'Gear' icon. Below is the HTML of the element:

<a id="reportViewMenu" title="Actions" class="imageButton1L" href="javascript:void(0)" role="menu" style="display: inline;"><span class="ariaLabel">Actions</span><img style="vertical-align:text-bottom;" src="/xmlpserver/static/v20220415.1218/theme/alta/images/toolbar/popupmenu_ena.png" alt="" border="0" onmouseover="this.src='/xmlpserver/static/v20220415.1218/theme/alta/images/toolbar/popupmenu_ovr.png'" onmouseout="this.src='/xmlpserver/static/v20220415.1218/theme/alta/images/toolbar/popupmenu_ena.png'" onmousedown="this.src='/xmlpserver/static/v20220415.1218/theme/alta/images/toolbar/popupmenu_dwn.png'"></a>

Here is my latest attempt at locating the element using Java:

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("'/html/body/table/tbody/tr/td/div/div/div/div/div[2]/div[1]/div/div[2]/a[2]'"))).click();

I've tried using relative xpath (using the attribute with ID, Title, and Class), cssSelector, and ID. Absolutely stuck on this so any help would be much appreciated.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

The desired element is a JavaScript enabled dynamic element.

To click on the element instead of visibilityOfElementLocated() you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategies:

  • Using cssSelector:

    new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a#reportViewMenu[title='Actions'] span.ariaLabel +img"))).click();
    
  • Using xpath:

    new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@id='reportViewMenu' and @title='Actions']//span[@class='ariaLabel' and text()='Actions']//following::img[1]"))).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks for the response. I'm still getting the same error using both of your techniques. Do you have any other suggestions I should look into? I've never worked with Selenium and was given this task, so am def a huge noob. – sqlboss4206969 Aug 09 '22 at 12:45
0

Using @undidected Selenium's xpath and

driver.switchTo().frame(0);

I was able to locate the element