[英]Vba: I want to find element by...(."<table class = "table table-bordered table-condensed table-striped text-center table-hover">") in selenium
我正在使用 Selenium.Driver 來查找應該在網頁中返回特定表格的 div class 元素。 雖然通過按標簽查找方法成功抽象了整個頁面,但我現在面臨的挑戰是,只返回頁面中的表格,除了表格 class 被列為“復合名稱”並且在 Selenium 中不受支持:I'我嘗試了 .xpath 和 .css 方法都沒有成功。 我的失敗可能是由於使用了錯誤的表達方式。
我的代碼:
設置 HTMLTables = HTMLDoc.FindElementsByTag("table")
' The above code returns all elements within the entire page.
' Instead of finding elements by "table" tag,
' I wanna FindElement(s)By...("table table-bordered table-condensed table-striped
text-center table-hover")
' The given code shall return ONLY the TABLE from within the entire page.
我在想:
Set HTMLTables = HTMLDoc.FindElementsBy...("table table-bordered table-condensed table-striped text-center table-hover")
如果您正在尋找所有復合 class 選擇這個
Dim Table As Selenium.WebElement
Set Table = driver.FindElementByXPath("//*[@class='table table-bordered table-condensed table- striped text-center table-hover']")
如果您正在尋找化合物 class 的一部分,您也可以使用
Dim FindBy As New Selenium.By
If Not driver.IsElementPresent(FindBy.Class("table-bordered table-condensed"), 3000) Then
driver.Quit
Exit Sub
Else
' do something ...
End If
或者
Dim FindBy As New Selenium.By
If Not driver.IsElementPresent(FindBy.Css(".table-bordered table-condensed")) Then
driver.Quit
Exit Sub
Else
' do something ...
End If
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.