• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to press 'Enter' once text is entered in the search field using Selenium WebDriver and VBA code in eclipse

bari2jitu

New Member
i want to press ENTER key in selinium web driver using vba code.

Code:
Sub chromeAuto()

    On Error Resume Next
    Dim GetText As String
    Dim obj As New WebDriver
    Dim lCount As Integer
    Dim keys As keys

lCount = Cells(Rows.Count, "A").End(xlUp).Row
'
    obj.Start "chrome", ""
    obj.Get "https://www.temweb.ford.com/maximo/ui/login"
    

    
    obj.FindElementByCss(".idp:nth-child(4) .largeTextNoWrap").Click
    obj.FindElementByCss("div:nth-child(3)").Click
    obj.FindElementById("titlebar_gotolink_4-lb1showmenu_goto_image").Click
    obj.FindElementByCss("#menu0_WO_MODULE_a_tnode").Click
    obj.FindElementByCss("#menu0_WO_MODULE_sub_changeapp_WOTRACK_a_tnode").Click
    


    Dim rng As Range, cell As Range
    Set rng = Work_order.Range("A2:A" & lCount)

        

    For Each cell In rng
        obj.FindElementById("m6a7dfd2f_tfrow_[C:1]_txt-tb").Click
        obj.SendKeys (cell)

'want to press Enter key here, so i use below codes but not working.
        obj.FindElementById("m6a7dfd2f_tfrow_[C:1]_txt-tb").SendKeys (keys.Enter)
        obj.FindElementByClass("fld text tablefilterfield  tt queryField").Submit
        obj.Actions.SendKeys (Enter)
        obj.FindElementByClass("fld text tablefilterfield  tt queryField").Submit
        obj.GoForward

' HTML code is here taken from inspect element in chrome.

<input datatype="1" id="m6a7dfd2f_tfrow_[C:1]_txt-tb" role="textbox" aria-labelledby="m6a7dfd2f_ttrow_[C:1]-c" class="fld text tablefilterfield  tt queryField" ctype="textbox" li="m6a7dfd2f_tfrow_[C:1]_txt-img" style=";width:75.0px;" ontr="true" async="1" ae="setvalue" type="text" value="" ov="" fldinfo="{&quot;query&quot;:true,&quot;eventpriority&quot;:1}" title="" originalvalue="" prekeyvalue="" stoptcclick="false">

    Next cell
 
below is working for me for a search box, you can try this once ".Submit" at the end

>>> use code - tags <<<
Code:
.FindElementById("quickSearchInput").SendKeys(Sheets("Home").txtTicketID).Submit
 
Last edited by a moderator:
Back
Top