简体   繁体   中英

Impossible intercept htmls instruction with vba

There is no way to intercept the instruction with vba, present on the htmls page with a Selenium command. Tried everything, find with Class, Id, CSS, nothing, nothing, nothing works. Maybe with the Path search method, but not knowing it I can't formulate it. Can anyone help me?

This is the html instruction:

<input type="text" name="search" value="" placeholder="Cerca per prodotto" class="form-control input-lg searchInputHeader"> 
    

I expect to be able to enter a value located on an excel sheet in the search field on the htmls page, using the <.sendkeys> instruction.

For example

.FindElementsByClass("form-control input-lg searchInputHeader").SendKeys Cells(4, VbaPosizione) 

but doesnt'work.

It looks like you are running into the "Compound class names not permitted error". This means that FindElementsByClass only accepts one class name.

If you want to select an element using multiple class names, you could to use a CSS selector like this (with a dot as prefix and no space between the different class names):

.FindElementByCss(".form-control.input-lg.searchInputHeader")

Also, a good pratice to debug you code is to split the step in multiple lines. For instance you could do the Selection and SendKeys seperatly:

    Dim MyInput As WebElement
    Set MyInput = MyWebDriver.FindElementByCss(".form-control.input-lg.searchInputHeader")
    MyInput.SendKeys "Some text"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM