Selenium VBA to insert text into an ID

Asked

Viewed 314 times

0

My code tries to copy from the windows Clipboard and paste into the site ID with VBA + Selenium.

Option Explicit

Public Sub PasteInfo()

Dim d As WebDriver, clipboard As Object, data As String
Set d = New ChromeDriver
Const url = "http://novosiebel.intranet.com.br"
d.Wait 20000

With d
    .Start "Chrome"
    .Get url
    [A1].Copy

    Set clipboard = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
    With clipboard
        .GetFromClipboard
        data = .GetText
    End With

    .FindElementById("1_SR_Number").SendKeys data
    Stop
    .Quit
End With
End Sub

it opens the site, I put the login and password, I click on the tab to enter but at the end of the execution it

erro de tempo de execução '7': NoSuchElementError Element not found for id=1-SR-Number

Do you have any idea what might be going wrong?

1 answer

0

This error happens because Selenium could not find the element with id="1_SR_Number". I suggest you try some of the options below:

  • Try to find the element using the Findelementbyxpath function
  • Put a Wait before the Findelement function, to allow time for everything to load
  • Check if the element you are looking for is not inside a Frame

Browser other questions tagged

You are not signed in. Login or sign up in order to post.