我试图确定下面图片/图标的元素。
注意:其他图标具有相同的// div [@class =' infor-collapsed-icon-img'所以我想我需要另一个唯一的ID来识别下面的确切元素。 ID是动态btw
这是我到目前为止尝试使用xpath:
1。)//div[@class='infor-collapsed-icon-img' and contains(@title,'Print Manager - Print Manager webpart allows the Lawson workspace user to contextually filter the print files of batch Jobs.')]
2。)//img[@title='Print Manager - Print Manager webpart allows the Lawson workspace user to contextually filter the print files of batch Jobs.']
3。)//img[contains(@title,'Print Manager - Print Manager webpart allows the Lawson workspace user to contextually filter the print files of batch Jobs.')]
对此有何想法?感谢
答案 0 :(得分:1)
试试这个XPath。首先选择repo2
,然后选择其中的div
标记。
img
编辑1:如果您要获取特定图片,则可以使用代码的"//div[@class='infor-collapsed-icon-img']/img"
属性获取该图片
id
或者按其顺序出现的索引。 (我推荐这个,因为它更干净)
"//img[@id='img_WebPartTitlect100_m_g_f26cdbcd_963c_46f4_94b1_c6a4fd7a9aab']"
编辑2 :尝试使用contains()
部分匹配文字。
"(//div[@class='infor-collapsed-icon-img']/img)[1]"
答案 1 :(得分:1)
您可以按ID
找到元素driver.findElement(By.id("imgId"));
Id是唯一的,因此您将拥有特定的元素。
在您的案例img_WebPartTitlect100...
中,在id
属性后查找src
属性。
修改:
您也可以尝试
driver.findElement(By.cssSelector("[title*='Print Manager']"));
这将为您提供包含“打印管理器”的标题的元素。
答案 2 :(得分:1)
如果你想要第一张图片
width
如果你想要第二张图片
Private Sub LondonC_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim connStr As String = ""
Dim Query As String
Query = "select week1 from table where username= @name AND week1 = 'found'"
Dim username = Login.txtusername.Text
Dim connection As New MySqlConnection(connStr)
COMMAND = New MySqlCommand(Query, connection)
connection.Open()
Dim READER As MySqlDataReader
READER = COMMAND.ExecuteReader
If (READER.Read() = True) Then
Query = "select * from table where username='" & Login.txtusername.Text & "'"
Dim week1 As String
week1 = READER("week1")
Button4.BackColor = Color.Red
Button4.Enabled = False
Button4.Text = "Completed"
End If
Catch ex As Exception
MsgBox("Error")
End Try
End Sub
希望它会对你有所帮助:)。
答案 3 :(得分:0)
试试这个:
driver.findElement(By.Xpath("//img[@src='your source']");
答案 4 :(得分:0)
试试这个:
//table[@class='infor-collapsed-pane']/tr[1]/td//img