本文整理匯總了C#中WatiN.Core.IE.CheckBox方法的典型用法代碼示例。如果您正苦於以下問題:C# IE.CheckBox方法的具體用法?C# IE.CheckBox怎麽用?C# IE.CheckBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WatiN.Core.IE
的用法示例。
在下文中一共展示了IE.CheckBox方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FetchEvents
/// <summary>
/// Screen Scrape Events
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
static List<EventDetail> FetchEvents(string query)
{
var eventDetails = new List<EventDetail>();
using (var _browser = new IE("http://www.gettyimages.com", false))
{
_browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Hide);
_browser.TextField(Find.ById("txtPhrase")).Clear();
_browser.TextField(Find.ById("txtPhrase")).TypeText(query);
var editorialChkfield = _browser.CheckBox(Find.ById("cbxEditorial"));
if (!editorialChkfield.Checked)
editorialChkfield.Click();
_browser.Button(Find.ById("btnSearch")).Click();
if (_browser.Link(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_lnkSeeMore")).Exists)
{
_browser.Link(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_lnkSeeMore")).Click();
_browser.Div(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_refinementContent")).WaitUntilExists();
var filterContentDiv = _browser.Div(Find.ById("ctl00_ctl00_ctl12_gcc_mc_re_flEvent_refinementContent"));
foreach (var link in filterContentDiv.Links.Filter(Find.ByClass("refineItem")))
{
var splitList = link.OuterHtml.Split('\'');
if (splitList.Length > 5)
eventDetails.Add(new EventDetail() { EventId = int.Parse(splitList[1]), EventName = splitList[5].Trim() });
}
}
}
return eventDetails;
}
示例2: RunPageTest
private static void RunPageTest(TestSettings settings)
{
string url;
using (var browser = new IE(ConfigurationManager.AppSettings["WebpageTestUrl"]))
{
browser.TextField(Find.ById("url")).Value = settings.Url;
if (!string.IsNullOrEmpty(settings.TestLocation))
browser.SelectList(Find.ById("location")).SelectByValue(settings.TestLocation);
if (!string.IsNullOrEmpty(settings.Browser))
browser.SelectList(Find.ById("browser")).SelectByValue(settings.Browser);
browser.Link(Find.ById("advanced_settings")).ClickNoWait();
if (!string.IsNullOrEmpty(settings.Speed))
browser.SelectList(Find.ById("connection")).SelectByValue(settings.Speed);
if (settings.IsPrivate)
browser.CheckBox(Find.ById("keep_test_private")).Change();
if (!string.IsNullOrEmpty(settings.Username))
browser.TextField(Find.ById("username")).TypeText(settings.Username);
if (!string.IsNullOrEmpty(settings.Password))
browser.TextField(Find.ById("password")).TypeText(settings.Password);
browser.Button(Find.ByName("submit")).Click();
browser.WaitUntilContainsText("First View", settings.Timeout);
if (browser.ContainsText("partially complete"))
{
Thread.Sleep(10000);
browser.Refresh();
}
browser.WaitUntilContainsText("Raw page data", settings.Timeout);
url = browser.Link(Find.ByText("Raw page data")).Url;
}
var csvRequest = (HttpWebRequest) WebRequest.Create(url);
csvRequest.Accept = "text/csv";
var data = new List<PageData>();
using (var stream = csvRequest.GetResponse().GetResponseStream())
{
if (stream != null)
{
using (var reader = new StreamReader(stream))
{
using (var context = new CsvReader(reader))
{
while (context.Read())
{
var counter = data.Count;
var item = new PageData();
item.EventName = counter == 0 ? "Empty Cache" : "Cached Run " + counter;
item.Url = context.GetField<string>(3);
item.LoadTime = TimeSpan.FromMilliseconds(context.GetField<int>(4));
item.TimeToFirstByte = TimeSpan.FromMilliseconds(context.GetField<int>(5));
item.Requests = context.GetField<int>(11);
data.Add(item);
}
}
}
}
}
var host = ConfigurationManager.AppSettings["MetricTracking:Host"];
var port = int.Parse(ConfigurationManager.AppSettings["MetricTracking:Port"]);
using (var metric = new MetricTracker(host, port))
{
foreach (var run in data)
{
Console.WriteLine(run.EventName + "\t" + run.LoadTime);
var prefix = settings.Prefix + run.EventName.Replace(" ", string.Empty) + ".";
metric.Timing(prefix + "LoadTime", run.LoadTime.TotalMilliseconds);
metric.Timing(prefix + "TimeToFirstByte", run.TimeToFirstByte.TotalMilliseconds);
metric.Value(prefix + "Requests", run.Requests);
}
}
}
示例3: GetPatentsInYear
private static void GetPatentsInYear(int year)
{
using (var browser = new IE(resource))
{
// go to the search form
browser.Button(Find.ByName("menu")).ClickNoWait();
// fill out search form and submit
browser.CheckBox(Find.ByName("brugsmodel")).Click();
browser.SelectList(Find.ByName("datotype")).Select("Patent/reg. dato");
browser.TextField(Find.ByName("dato")).Value = string.Format("{0}*", year);
browser.Button(Find.By("type", "submit")).ClickNoWait();
browser.WaitForComplete();
// go to first patent found in search result and save it
browser.Buttons.Filter(Find.ByValue("Vis")).First().Click();
GetPatentFromPage(browser, year);
// hit the 'next' button until it's no longer there
while (GetNextPatentButton(browser).Exists)
{
GetNextPatentButton(browser).Click();
GetPatentFromPage(browser, year);
}
}
}
示例4: GetCheckBox
public static WatiN.Core.CheckBox GetCheckBox(IE ie, HControl control)
{
switch (control.Attribute.ToLower())
{
case AttributeType.Id:
{
CheckBox txt = ie.CheckBox(Find.ById(control.Value));
if (txt.Exists)
return txt;
return null;
}
case AttributeType.Name:
{
CheckBox txt = ie.CheckBox(Find.ByName(control.Value));
if (txt.Exists)
return txt;
return null;
}
case AttributeType.Class:
{
CheckBox txt = ie.CheckBox(Find.ByClass(control.Value));
if (txt.Exists)
return txt;
return null;
}
case AttributeType.Text:
{
CheckBox txt = ie.CheckBox(Find.ByText(control.Value));
if (txt.Exists)
return txt;
return null;
}
case AttributeType.Value:
{
CheckBox txt = ie.CheckBox(Find.ByValue(control.Value));
if (txt.Exists)
return txt;
return null;
}
default:
{
CheckBox txt = ie.CheckBox(Find.ById(control.Value));
if (txt.Exists)
return txt;
return null;
}
}
}
示例5: FindControlInBrowserByID
public static object FindControlInBrowserByID(IE ie, string strID, Enumerators.ControlType ctrl)
{
if (ctrl == Enumerators.ControlType.Span)
{
Span sp = ie.Span(Find.ById(strID));
Assert.IsTrue(sp.Exists, "Could not Find: " + strID);
return sp;
}
else if (ctrl == Enumerators.ControlType.Link)
{
Link lnk = ie.Link(Find.ById(strID));
Assert.IsTrue(lnk.Exists, "Could not Find: " + strID);
return lnk;
}
else if (ctrl == Enumerators.ControlType.Frame)
{
Frame iFrame = ie.Frame(Find.ById(strID));
return iFrame;
}
else if (ctrl == Enumerators.ControlType.Image)
{
Image img = ie.Image(Find.ById(strID));
Assert.IsTrue(img.Exists, "Could not Find: " + strID);
return img;
}
else if (ctrl == Enumerators.ControlType.TableCell)
{
TableCell tCell = ie.TableCell(Find.ById(strID));
Assert.IsTrue(tCell.Exists, "Could not Find: " + strID);
return tCell;
}
else if (ctrl == Enumerators.ControlType.Table)
{
Table tbl = ie.Table(Find.ById(strID));
Assert.IsTrue(tbl.Exists, "Could not Find: " + strID);
return tbl;
}
else if (ctrl == Enumerators.ControlType.TableRow)
{
TableRow row = ie.TableRow(Find.ById(strID));
Assert.IsTrue(row.Exists, "Could not Find: " + strID);
return row;
}
else if (ctrl == Enumerators.ControlType.CheckBox)
{
CheckBox chk = ie.CheckBox(Find.ById(strID));
Assert.IsTrue(chk.Exists, "Could not Find: " + strID);
return chk;
}
else if (ctrl == Enumerators.ControlType.Button)
{
Button btn = ie.Button(Find.ById(strID));
Assert.IsTrue(btn.Exists, "Could not Find: " + strID);
return btn;
}
else if (ctrl == Enumerators.ControlType.TextField)
{
TextField txt = ie.TextField(Find.ById(strID));
Assert.IsTrue(txt.Exists, "Could not Find: " + strID);
return txt;
}
else if (ctrl == Enumerators.ControlType.SelectList)
{
SelectList sList = ie.SelectList(Find.ById(strID));
Assert.IsTrue(sList.Exists, "Could not Find: " + strID);
return sList;
}
else if (ctrl == Enumerators.ControlType.Div)
{
Div division = ie.Div(Find.ById(strID));
Assert.IsTrue(division.Exists, "Could not Find: " + strID);
return division;
}
else if (ctrl == Enumerators.ControlType.TableRow)
{
TableRow tRow = ie.TableRow(Find.ById(strID));
Assert.IsTrue(tRow.Exists, "Could not Find: " + strID);
return tRow;
}
else if (ctrl == Enumerators.ControlType.FileUpload)
{
FileUpload fileUpload = ie.FileUpload(Find.ById(strID));
Assert.IsTrue(fileUpload.Exists, "Could not find: " + strID);
return fileUpload;
}
else
{
return null;
}
}
示例6: FindControlInBrowserByCustom
public static object FindControlInBrowserByCustom(IE ie, string strCustomAttribute, string strToFind,
Enumerators.ControlType ctrl)
{
if (ctrl == Enumerators.ControlType.Span)
{
Span sp = ie.Span(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(sp.Exists, "Could not Find: " + strToFind);
return sp;
}
else if (ctrl == Enumerators.ControlType.Link)
{
Link lnk = ie.Link(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(lnk.Exists, "Could not Find: " + strToFind);
return lnk;
}
else if (ctrl == Enumerators.ControlType.Frame)
{
Frame frame = ie.Frame(Find.By(strCustomAttribute, strToFind));
Assert.AreEqual(frame.Name, strToFind);
return frame;
}
else if (ctrl == Enumerators.ControlType.Image)
{
Image img;
if (strCustomAttribute == "src")
{
img = ie.Image(Find.BySrc(strToFind));
}
else
{
img = ie.Image(Find.By(strCustomAttribute, strToFind));
}
Assert.IsTrue(img.Exists, "Could not Find: " + strToFind);
return img;
}
else if (ctrl == Enumerators.ControlType.TableCell)
{
TableCell tCell = ie.TableCell(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(tCell.Exists, "Could not Find: " + strToFind);
return tCell;
}
else if (ctrl == Enumerators.ControlType.Table)
{
Table tbl = ie.Table(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(tbl.Exists, "Could not Find: " + strToFind);
return tbl;
}
else if (ctrl == Enumerators.ControlType.TableRow)
{
TableRow row = ie.TableRow(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(row.Exists, "Could not Find: " + strToFind);
return row;
}
else if (ctrl == Enumerators.ControlType.CheckBox)
{
CheckBox chk = ie.CheckBox(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(chk.Exists, "Could not Find: " + strToFind);
return chk;
}
else if (ctrl == Enumerators.ControlType.Button)
{
Button btn = ie.Button(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(btn.Exists, "Could not Find: " + strToFind);
return btn;
}
else if (ctrl == Enumerators.ControlType.TextField)
{
TextField txt = ie.TextField(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(txt.Exists, "Could not Find: " + strToFind);
return txt;
}
else if (ctrl == Enumerators.ControlType.SelectList)
{
SelectList sList = ie.SelectList(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(sList.Exists, "Could not Find: " + strToFind);
return sList;
}
else if (ctrl == Enumerators.ControlType.Div)
{
Div div = ie.Div(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(div.Exists, "Could not Find: " + strToFind);
return div;
}
else
{
return null;
}
}