將 vba 與 selenium 一起使用我試圖在下拉框中進入 BO_test 的選項值并單擊。我嘗試了很多東西。這是最后一次嘗試:
Option Explicit
Private ch As Selenium.ChromeDriver
Sub test()
Dim FindBy As New Selenium.By
Dim ResultSections As Selenium.WebElements
Dim ResultSection As Selenium.WebElement
Dim ResultSections2 As Selenium.WebElements
Dim ResultSection2 As Selenium.WebElement
Dim TableByTag As Selenium.WebElement
Dim tr, c, r, td, li, cc, t, columnC, rowc
Dim size As Integer
Dim currentWindow As Selenium.Window
Dim html As HTMLDocument
Set ch = New Selenium.ChromeDriver
ch.Start baseUrl:=""
ch.Get "/"
With ch
Set ResultSections2 = .FindElementsById("SPFrameWorkTable")
For Each ResultSection2 In ResultSections2
Application.Wait Now TimeValue("00:00:2")
'Debug.Print ResultSection2.Text
.FindElementById("AQPanelQueryList").Click
.FindElementById("SPSideContainerTD").Click
Next ResultSection2
End With
end sub
這是除錯輸出的內容: 查詢管理查詢:(添加新查詢)BO_test 設定為默認 選中時運行查詢 選中時清除表單 條件:匹配所有匹配任何附加欄位選擇
---html---
<lable class="SPLayoulTable" cellspacing="0" cellpadding="0">
<tbody
<tr> </tr>
}<tr> </tr>
<tr>
<td>
<div id="SPFormDiv" class="SPFormDiv" style="width: 350px; height: 782px; overflow: auto;"> == $0
<table aginfotop="truc" class"SPLayoutTable" id="AQContentTable">
<tbody>
<tr>
<td style="width: 20%">...</td>
<td align="left" style="width: 80%">
(select id="AQranclQueryList">
<optgroup label="My Queries">
<option value="(new)">(add new query)</option>
<option value="7c5a41f1-bala-444a-b7d0-97f5c1ce5052">BO_test</option>
</optgroup>
</sclcct>
</td>
</tr>
* <tr> </tr>
<tr> </tr>
uj5u.com熱心網友回復:
嘗試這個。
Public MyElement As Selenium.WebElement
Sub Test()
' ...
Set MyElement = MyBrowser.FindElementById("YourDropdownBox")
MyElement.WaitDisplayed
If MyElement.IsDisplayed Then
MyElement.Click
MyElement.AsSelect.SelectByText ("BO_test")
End If
' ...
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/346581.html
上一篇:自定義自動完成不會超出div
下一篇:CSS-將邊框半徑應用于gif
