如何使用Selenium获取我在文本区域中输入的文本,其中在Chrome和Mozilla中的开发人员选项中输入的文本在IE中在开发人员部分中可见。使用gettext()我可以从IE获取文本,但是对于Chrome和Mozilla,我没有使用相同的内容。
string text =
driver.findelement(
by.xpath("//textarea[@placeholder='Enter a description']")
).gettext();
答案 0 :(得分:0)
试试这个:
Option Explicit
Sub Step_6_test()
Dim FilePath As String
Dim CellData As String
Dim LastCol As Long
Dim LastRow As Long
Dim i As Long, j As Long
LastCol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
LastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
CellData = ""
FilePath = Application.DefaultFilePath & "\auth.txt"
Open FilePath For Output As #2
For i = 1 To LastRow
For j = 1 To LastCol
If j = LastCol Then
CellData = CellData + Trim(Cells(i, j).Value)
Else
CellData = CellData + Trim(Cells(i, j).Value) + ","
End If
Next j
Write #2, CellData
CellData = ""
Next i
Close #2
MsgBox ("Done")
End Sub
答案 1 :(得分:0)
以下属性之一应使用以下内容获取文本:
答案 2 :(得分:0)
提供模糊的解决方案,因为没有HTML
很难建议String text=driver.findelement(By.xpath("//textarea[@placeholder='Enter a description']")).getAttribute("innerHTML")//or .getAttribute("outerHTML") ;
使用字符串函数获取所需的值!