Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need some help. Chrome (v 75.0.3770.100) using Selenium Basic ChromeDriver (v 75.0.3770.140) in Excel (2013) VBE. There's an input box which generates a dynamic list if the customer id# exists. I wish to fill in the customer id# then select from the dynamic drop down. But first step, I'm struggling to input my text to the box. I'm able to click on the box with

obj.FindElementById("selectcustTxt").Click

but when I try to fill in the box with:

obj.FindElementById("selectcustTxt").Value = "1111"

I get an error Run-time error '424': Object required

I tried the following FindElementByXPath with both .Value and .Text but get the same Run-time error '424': Object required

obj.FindElementByXPath("//input[@class='form-control cust-autosuggest ng-pristine ng-valid ng-touched'][@id='selectcustTxt']").Value = "1111"

Here's the HTML:

<div class="form-group search-field"><input id="selectcustTxt" type="text" class="form-control cust-autosuggest ng-valid ng-touched ng-dirty ng-valid-parse" autocomplete="off" plshholder="Enter Cust name" autocomplepte="off" ng-model="cust" suggest-type="custService" sh-autosuggest="custAddresses" data-validation="required">
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
788 views
Welcome To Ask or Share your Answers For Others

1 Answer

To send a character sequence within the desired element you can use either of the following Locator Strategies:

  • Using FindElementByCss:

    obj.FindElementByCss("input.form-control.cust-autosuggest.ng-valid.ng-touched.ng-dirty.ng-valid-parse#selectcustTxt").SendKeys ("1111")
    
  • Using FindElementByXPath:

    obj.FindElementByXPath("//input[@class='form-control cust-autosuggest ng-valid ng-touched ng-dirty ng-valid-parse' and @id='selectcustTxt']").SendKeys ("1111")
    

Reference

You can find a couple of relevant discussions in:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...