2017-12-05 17 views
0

IDを持たない入力フィールドにテキストを入力しようとしています。要素を調べると、次のようになります。VBA - IEオートメーション - .getelements

<input title="Affected Customer(s)" class="custom-input ng-pristine ng-invalid ng-invalid-required ng-touched" role="combobox" aria-expanded="false" aria-required="true" aria-owns="typeahead-78-1606" aria-autocomplete="list" required="" type="text" placeholder="Enter customer name, email, login ID or corporate ID" entity="incident" field-name="customer.loginId" potentially-required-field="" auto-focus="" typeahead="user as user.firstName + ' ' + user.lastName for user in getList('person', $viewValue)" typeahead-loading="person.isLoading" typeahead-wait-ms="500" typeahead-on-select="onCustomerSelect($model)" typeahead-template-url="views/create/custom-add-user-dropdown.html" typeahead-min-length="3" prevent-click-event="" ng-model="person.ngModel"> 

この入力フィールドの参照方法を教えてください。私は多くの方法を試みましたが、それらはすべて失敗します。私の理解は不足していると思います。うまくいけば、ちょっとした助けが私を正しい道に導きます。私は今、それがこの入力フィールドを検索しようとしていたコードです:

Sub Automate_IE_Load_Page() 
'This will load a webpage in IE 
Dim i As Long 
Dim URL As String 
Dim IE As Object 
Dim objElement As Object 
Dim objCollection As Object 
Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element 

'Create InternetExplorer Object 
Set IE = CreateObject("InternetExplorer.Application") 

'Set IE.Visible = True to make IE visible, or False for IE to run in the background 
IE.Visible = True 

'Define URL 
URL = "https://ewpg-app-1041.hydro.mb.ca/ux/smart-it/#/create/incident" 

'Navigate to URL 
IE.navigate URL 



' Wait while IE loading... 
'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop) 
Do While IE.readyState = 4: DoEvents: Loop 'Do While 
Do Until IE.readyState = 4: DoEvents: Loop 'Do Until 


objIE.Document.getElementsByName("customer.loginId")(0).Value = "test" 

'click create new 
'for each <a> element in the collection of objects with class of 'result__a'... 
For Each aEle In objIE.Document.getElementsByName("Affected Customer(s)") 

    '...get the href link and print it to the sheet in col C, row y 
    result = aEle 

'repeat times the # of ele's we have in the collection 
Next 


'Unload IE 
Set IE = Nothing 
Set objElement = Nothing 
Set objCollection = Nothing 

End Sub 

ライン「objIE.Document.getElementsByName(」customer.loginIdは「)(0).Valueの= 『テスト』は」私にエラーを与えます実行時エラー424 - オブジェクトが必要です。

ご協力いただきありがとうございます。これはおそらく非常に簡単ですが、私は何か基本的なことを明らかに理解していません。上記のコードはさまざまなサイトから取得され、うまく動作しているようです。私は別のロジックを使ってテストするために働いていました。

答えて

0

代わりに、コードの下に試してみてください。

getElementsByClassName("custom-input ng-pristine ng-invalid ng-invalid-required ng-touched") 
+0

をああ...なるほど。私は今日働くことを試みるときにそれを試みます。ありがとうございました。 –

+0

あなたのコードを試しましたが、それでも私には実行時エラー424 - オブジェクトが期待されています。 –

+0

それは動作するようになった!!!!!!! objIE.document.getElementsByClassName( "カスタム入力ng-pristine ng-invalid ng-invalid-required ng-touched")(0).Value = "test" なぜ以前はうまくいかなかったのかわかりません。 –

関連する問題