Home > OS >  VBA button not clicking - element not visible error
VBA button not clicking - element not visible error

Time:07-26

I'm trying to click a button using a VBA Chrome driver via Selenium but I get an ElementNotVisibleError

The HTML code for the button is -

<button  id="primary-button" classnames="primary-button" title="Continue">Continue</button>

I've tried to check the element exists and VBA returns TRUE for the following -

MyBrowser.IsElementPresent(Findby.ID("primary-button"))

but when I try to click the button using the following code, i get the error -

MyBrowser.FindElementById("primary-button").Click

CodePudding user response:

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

  • Using FindElementByCss:

    MyBrowser.FindElementByCss("button.base-button#primary-button[title='Continue']").Click
    
  • Using FindElementByXPath:

    MyBrowser.FindElementByXPath("//button[@class='base-button' and @id='primary-button'][@title='Continue' and text()='Continue']").Click
    
  • Related