'VBA Selenium: Selecting a button behind multiple div tags

I was using selenium with VBA and there is the current webpage. I was trying to get the bot to select the "exportbutton" ID, but I have already tried Findelementbyxpath etc., and the error is always returned saying it cannot locate that ID. It looks like the button is behind multiple divs and I am not sure how to select it. I have already looked through for iframes and there are none present in the webpage. How can I select this button behind this header.

Button Snapshot:

HTML Code



Solution 1:[1]

The <button> element have the id, class and tittle attributes.

<button id="exportbtn" class="button2" title="Save the report in a file (pdf, excel, ...)">

Solution

To click on the element you can use either of the following locator strategies:

  • Using FindElementByCss:

    d.FindElementByCss("button#exportbtn[title='Save the report in a file (pdf, excel, ...)'] > span").click
    
  • Using FindElementByXPath:

    d.FindElementByXPath("//button[@id='exportbtn' and @title='Save the report in a file (pdf, excel, ...)']/span").click
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 undetected Selenium