How to choose specific data on a dropdown element with >input element

ivankesaulya

New Member
Joined
Feb 2, 2018
Messages
6
Hi All,

I really need your favor today

So there's this task on my workplace that i have to do it manually and i don't wanna do it manually.

I browsed youtube and landed on WiseOwlTutorials and i found one of the video that taught me how to choose from dropdown area on a website.

https://www.youtube.com/watch?…RWICj_clM&index=15&t=185s

but unfortunately the video only focused on elements with "> select" in front of it while on my screen it shows "> input" Screenshot

So my problem is whenever i run my macro with specific agents which contains "agentbk17" it will automatically choose the first available option available rather than selecting the right selection based on data i input Screenshot while the right selection is on the bottom list Screenshot but when i run it with "agentbk595" there is nothing wrong.

I kindly do need your help on this.

Thank you very much for your help.

Ivan

VBA Code:
Option Explicit
Private cd As Selenium.ChromeDriver
Sub Reassign()
    
    Dim FindBy As New Selenium.By
    Dim lr As Long, i As Long
    Dim t As Long
    Dim Agent As Variant
    Dim opl As Selenium.WebElement
    'Dim ddl As Selenium.SelectElement
    
    'Set FindBy = New Selenium.By
    Set cd = New Selenium.ChromeDriver
    'Set opl = WaitForElement(byId, "s2id_autogen6109_search")
    'element.AsSelect.SelectByText .SendKeys.Cells(i, "D")
    'set ddl = cd.FindElementByName.AsSelect
    
    cd.Start
    cd.Get "http://ekiwi.id.tmsapp.net/index.php"
    cd.Wait (3000)
    
    'If Not ch.IsElementPresent(FindBy.Class("button buttonBlue")) Then
    'End If
    
    'If different user please change username and password
    cd.FindElementByName("username").SendKeys "teamlead333@ekiwiID.com"
    cd.FindElementByName("password").SendKeys "dePMlQ60jL"
    cd.FindElementByCss("#loginFormDiv > form > div:nth-child(6) > button").Click
    cd.Wait (3000)
    cd.FindElementByCss("#sidebarnav > li:nth-child(5) > a > i").ClickDouble
    cd.Wait (3000)
    cd.FindElementByCss("#sidebarnav > li:nth-child(5) > ul > li:nth-child(2) > a > i").Click
    cd.Wait (3000)
    cd.FindElementByCss("#appnav > ul > div > button.btn.module-buttons.btn-bhs.btn-filter-header.filter > span").Click
    cd.Wait (3000)
    
    
With Sheet1

lr = Sheet1.Cells(Rows.Count, "B").End(xlUp).Row
Agent = Sheet1.Cells(Rows.Count, "D").End(xlUp).Row

t = 1

    For i = 3 To lr
    
    'Doubleclick Selection iniside leadid box
    'ch.FindElementByCss("#tblMailList0_wrapper > div:nth-child(2) > div > div > div.dataTables_scrollHead > div > table > thead > tr.bhs-filter.ddd > th:nth-child(2) > span > input").ClickDouble
    'Clear any text or string inside leadid box
    'ch.FindElementByCss("#tblMailList0_wrapper > div:nth-child(2) > div > div > div.dataTables_scrollHead > div > table > thead > tr.bhs-filter.ddd > th:nth-child(2) > span > input").Clear
    'Clear Filter
    cd.FindElementByCss("#appnav > ul > div > button.btn.module-buttons.btn-bhs.filter.btn-clear-filter > i").Click
    cd.Wait (3000)
    'Paste leadid from excel
    cd.FindElementByCss("#tblMailList0_wrapper > div:nth-child(2) > div > div > div.dataTables_scrollHead > div > table > thead > tr.bhs-filter.ddd > th:nth-child(2) > span > input").SendKeys .Cells(i, "B")
    'Enter function
    cd.FindElementByCss("body").Click
    cd.Wait (4000)
    'Select leadid by checkbox
    cd.FindElementByCss("#tblMailList0 > tbody > tr > td:nth-child(1) > input").Click
    cd.Wait (3000)
    'Reassign leadid
    cd.FindElementByCss("#btnReassign").Click
    cd.Wait (2000)
    cd.FindElementByCss("#s2id_selected-agent > a > span.select2-arrow > b").Click
    cd.Wait (2000)
    cd.FindElementByCss(".select2-input.ignore-validation.select2-focused").SendKeys .Cells(i, "D")
    
    cd.FindElementByClass("select2-result-label").Click
    cd.FindElementById("add-to-order-list").Click
    cd.FindElementByCss("#assign-agent").Click
    cd.Wait (2000)
    
    
    t = t + 1
    
Next

End With

cd.Close
MsgBox "Macro Done"

End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top