contact
Sub Demo()
Dim row_number As Long, count_of_str As Long
Dim rToSearch As Range, rFound As Range, rng As Range
Dim strSearchTerm As String
Dim FirstAddr As String
Dim ws As Worksheet, rDest As Range
Dim cl As Range, ar As Range
strSearchTerm = "name"
With Sheets("Sheet1")
Set rToSearch = .Range(.Cells(5, 8), .Cells(.Rows.Count, 8).End(xlUp))
End With
Set rng = rToSearch.Find( _
What:=strSearchTerm, _
After:=rToSearch.Cells(rToSearch.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not rng Is Nothing Then
FirstAddr = rng.Address
Do
count_of_str = count_of_str + 1
If rFound Is Nothing Then
Set rFound = rng.Offset(0, 1)
Else
Set rFound = Union(rFound, rng.Offset(0, 1))
End If
Set rng = rToSearch.FindNext(rng)
Loop Until rng.Address = FirstAddr
End If
MsgBox "the str occured: " & count_of_str & " times."
' rFound now refers to all found cells
' Copy to somewhere
Set ws = Worksheets("YourDestinationSheet") '<~~Update as required
Set rDest = ws.Range("YourDestinationRange") '<~~Update as required
If Not rFound Is Nothing Then
rFound.Copy rDest '<~~ copy names
rFound.Offset(1, 0).Copy rDest.Offset(0, 1) '<~~ copy contacts
End If
' Process found cells
' eg
If Not rFound Is Nothing Then
For Each ar In rFound.Areas
For Each cl In ar.Cells
Debug.Print cl.Address
Next cl, ar
End If
End Sub
&#34 ;.
我尝试使用package p111;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Yahoo_c
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
WebDriver wi= new FirefoxDriver();
wi.get("https://in.yahoo.com/?p=us");
WebElement q=wi.findElement(By.xpath("//*[starts-with(.,'UHSearch')]")); q.sendKeys("pizza");
}
}
//Actual xpath is :
,但它不起作用。
有什么想法吗?
答案 0 :(得分:0)
你犯了2个错误。
使用以下元素查找器:
xpath://input[@id='UHSearchBox']
id:id= UHSearchBox
css = input[id='UHSearchBox']
或#UHSearchBox