本文整理汇总了C#中WebDriverWait.SendKeys方法的典型用法代码示例。如果您正苦于以下问题:C# WebDriverWait.SendKeys方法的具体用法?C# WebDriverWait.SendKeys怎么用?C# WebDriverWait.SendKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.SendKeys方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLocation
public Location GetLocation(string urlRe, string province, string district, string pacelNo)
{
var result = new Location();
var parcel = 0;
if (string.IsNullOrEmpty(province) || string.IsNullOrEmpty(district) || string.IsNullOrEmpty(pacelNo))
{
return result;
}
if (pacelNo.Contains("-"))
{
var stat = int.TryParse(pacelNo.Split('-')[0], out parcel);
if (!stat)
return result;
}
else
{
var stat = int.TryParse(pacelNo, out parcel);
if (!stat)
return result;
}
var loc = DataHelper.GetLocation(province, district, parcel);
if (loc != null)
{
return loc;
}
string driverPath = @"D:\MyProjects\FRES\src\FRES.Source.Map\Drivers\";
IWebDriver driver = new OpenQA.Selenium.PhantomJS.PhantomJSDriver(driverPath);
//IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(driverPath);
try
{
var url = "http://dolwms.dol.go.th/tvwebp/";
driver.Navigate().GoToUrl(url);
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(TIMEOUT));
Thread.Sleep(DELAY);
var ddlProvince = driver.FindSelectElementWhenPopulated(By.Name("ddlProvince"), TIMEOUT);
ddlProvince.SelectBySubText(province);
Thread.Sleep(DELAY);
var ddlAmphur = driver.FindSelectElementWhenPopulated(By.Name("ddlAmphur"), TIMEOUT);
ddlAmphur.SelectBySubText(district);
Thread.Sleep(DELAY);
var txtPacelNo = new WebDriverWait(driver, TimeSpan.FromSeconds(TIMEOUT)).Until(ExpectedConditions.ElementExists(By.Name("txtPacelNo")));
txtPacelNo.SendKeys(pacelNo);
Thread.Sleep(DELAY);
var btnFind = driver.FindElement(By.Name("btnFind"));
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].click();", btnFind);
Thread.Sleep(DELAY);
//var element = new WebDriverWait(driver, TimeSpan.FromSeconds(3)).Until(ExpectedConditions.TextToBePresentInElement(driver.FindElement(By.Id("ddlAmphur")), "01"));
//wait.Until(ExpectedConditions.ElementExists(By.CssSelector("div[style=\"transform: translateZ(0px); position: absolute; left: 0px; top: 0px; z-index: 107; width: 100%;\"]")));
var isExist = wait.Until((d) => { return driver.PageSource.Contains("createMarker( new Array("); });
if (isExist)
{
var html = driver.PageSource;
html = GetStrBtw(html, "createMarker( new Array(", "));");//.Replace("'", string.Empty);
var dtls = html.Split(',').Select(x => x.Replace("'", "")).ToArray();
result = new Location
{
Amphur = district,
Province = province,
ParcelCode = parcel,
Lat = double.Parse(dtls[7]),
Lon = double.Parse(dtls[8])
};
DataHelper.InsertLocation(result);
}
else
{
throw new Exception("Can't find location");
}
}
catch (Exception ex)
{
lock (sync)
File.AppendAllText("D:/RE/M.log", DateTime.Now.ToString("yyyyMMdd HH:mm") + "," + province + "," + district + "," + parcel + "," + urlRe + "," + ex.GetBaseException().Message + "\r\n");
}
finally
{
//Thread.Sleep(3000);
driver.Close();
driver.Quit();
driver.Dispose();
}
return result;
}