1

Upon running my script , I get stuck with element not visible error in vba with selenium. Here is the code I was trying with:

Sub Table_stuff()

Dim driver As New WebDriver

With driver
    .Start "chrome", "http://apps.tga.gov.au/Prod/devices"
    .get "/daen-entry.aspx"
    .Timeouts.PageLoad = 20000
    .FindElementById("disclaimer-accept").Click
    .Timeouts.PageLoad = 20000
    .FindElementById("medicine-name").SendKeys ("pump") ''Error thrown here
    .FindElementById("medicines-header-text").Click
    .FindElementById("submit-button").Click
    .Timeouts.PageLoad = 20000
End With
End Sub

Here is the element reaching where my scraper throws that specific error:

<input type="text" name="medicine-name" id="medicine-name" value="" 
placeholder="Type at least 3 characters" title="Enter medical device name" 
autocomplete="off" maxlength="100" class="placeholder" style="color: rgb(0, 0, 0);">
2
  • Is the element actually visible in a browser? Commented Jul 9, 2017 at 22:53
  • Yep, element is visible in the browser. Commented Jul 9, 2017 at 23:10

2 Answers 2

2

From what I understand Timeouts.PageLoad call would not actually trigger selenium driver to wait - I think it just sets a page load timeout. Which means that your code would try to send keys to the search input at the moment of the opened license dialog - which triggers the "element not visible" error.

What you need is a Wait call (well, ideally an Explicit Wait, but I am not sure if VBA bindings have that functionality):

.Wait 3000  ''3 seconds
Sign up to request clarification or add additional context in comments.

Comments

1

Replacing FindById with XPath to get the title, which accepts input, should work.

Here is the code snippet:

.FindElementByXPath("//input[@title='Enter medical device name']").SendKeys ("pump")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.