本文整理匯總了C#中WatiN.Core.IE類的典型用法代碼示例。如果您正苦於以下問題:C# IE類的具體用法?C# IE怎麽用?C# IE使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IE類屬於WatiN.Core命名空間,在下文中一共展示了IE類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LoginUser
/// <summary>
/// Logins the user.
/// </summary>
/// <param name="browser">The <paramref name="browser"/> instance.</param>
/// <param name="userName">Name of the user.</param>
/// <param name="userPassword">The user password.</param>
/// <returns>If User login was successfully or not</returns>
public static bool LoginUser(IE browser, string userName, string userPassword)
{
// Login User
browser.GoTo("{0}yaf_login.aspx".FormatWith(TestConfig.TestForumUrl));
// Check If User is already Logged In
if (browser.Link(Find.ById(new Regex("_LogOutButton"))).Exists)
{
browser.Link(Find.ById("forum_ctl01_LogOutButton")).Click();
browser.Button(Find.ById("forum_ctl02_OkButton")).Click();
}
browser.GoTo("{0}yaf_login.aspx".FormatWith(TestConfig.TestForumUrl));
browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
browser.TextField(Find.ById(new Regex("Login1_UserName"))).TypeText(userName);
browser.TextField(Find.ById(new Regex("Login1_Password"))).TypeText(userPassword);
browser.Button(Find.ById(new Regex("LoginButton"))).ClickNoWait();
browser.GoTo(TestConfig.TestForumUrl);
return browser.Link(Find.ById(new Regex("LogOutButton"))).Exists;
}
示例2: GettingHtml
public static HtmlNode GettingHtml(IE browser)
{
var doc = new HtmlDocument(); //install parsed doc in HTML Agility Pack
doc.LoadHtml(browser.Body.OuterHtml); //place html in parser from Bank.Gov
var dataBlock = doc.DocumentNode.SelectSingleNode("//div[@class=\"content\"]");
return dataBlock;
}
示例3: 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;
}
示例4: Solve
public void Solve(string url)
{
_browser = new IE(url);
_puzzle = ParsePuzzle();
var solver = new Solver();
//solver.Reduced += SolverOnReduced;
solver.Solve(_puzzle);
SolverOnReduced(null, null);
if (_puzzle.IsSolved)
{
return;
}
if (File.Exists("e:\\out.html"))
{
File.Delete("e:\\out.html");
}
File.WriteAllText("e:\\out.html", GetPuzzleHtml());
}
示例5: home_page_should_have_vidpub_name
public void home_page_should_have_vidpub_name() {
using (var browser = new IE("http://localhost:1701")) {
Assert.True(browser.Title.Contains("VidPub"));
}
}
示例6: CloseIEInstance
/// <summary>
/// Closes the given IE instance.
/// </summary>
/// <param name="ieInstance">The IE instance to be closed.</param>
public static void CloseIEInstance(IE ieInstance)
{
if (ieInstance != null)
{
ieInstance.Close();
}
}
示例7: ForceBrowserClose
public Result ForceBrowserClose(bool forceClose)
{
if (isLocal || forceClose)
{
try
{
browser = new IE(Urls.Root);
browser.WaitForComplete();
}
catch (Exception e)
{
Console.WriteLine("BaseFixture.ForceBrowserForDatabaseReset: " + e.ToString());
Thread.Sleep(500);
browser = new IE(Urls.Root);
browser.WaitForComplete();
}
CloseBrowser(forceClose);
}
return Result.CreatePass();
}
示例8: GetControl
public static AttributeConstraint GetControl(IE ie, HControl control)
{
//Regex regex = new Regex(FilterPattern.GetToPattern(control.Value));
String regex = control.Value;
switch (control.Attribute.ToLower())
{
case AttributeType.Id:
return Find.ById(regex);
case AttributeType.Name:
return Find.ByName(regex);
case AttributeType.Class:
return Find.ByClass(regex);
case AttributeType.Text:
{
Regex regexs = new Regex(FilterPattern.GetToPattern(control.Value));
return Find.ByText(regexs);
}
case AttributeType.Value:
{
Regex regexs = new Regex(FilterPattern.GetToPattern(control.Value));
return Find.ByValue(regexs);
}
default:
return Find.ByName(regex);
}
}
示例9: frmWebBowser_Load
private void frmWebBowser_Load(object sender, EventArgs e)
{
webBrowser1.ScriptErrorsSuppressed = true;
//IE.Settings.AutoStartDialogWatcher = false;
WatiN.Core.Settings.AutoStartDialogWatcher = false;
ie = new IE(webBrowser1.ActiveXInstance);
}
示例10: HomePageContainsFreshOffTheGrillAlbumList
public void HomePageContainsFreshOffTheGrillAlbumList()
{
using (var browser = new IE("http://localhost:1200/"))
{
Assert.IsTrue(browser.List(Find.ById("album-list")).Children().Any());
}
}
示例11: Goto
public static string Goto(String text, IE ie)
{
int i = 0;
while (i < Loop)
{
i++;
try
{
ie.GoTo(text);
ie.WaitForComplete();
//ie.WaitUntilContainsText("message");
return string.Empty;
}
catch (Exception ex)
{
if (i == Loop)
{
return ex.Message;
}
ie.Close();
Thread.Sleep(60000);
ie.Reopen();
}
}
return string.Empty;
}
示例12: HomePageContainsPromotionPanel
public void HomePageContainsPromotionPanel()
{
using (var browser = new IE("http://localhost:1200/"))
{
Assert.IsTrue(browser.Div(Find.ById("promotion")).Exists);
}
}
示例13: Solve
public void Solve(string url)
{
_browser = new IE(url);
_puzzle = ParsePuzzle();
var solver = new GuessingSolver();
// solver.Reduced += SolverOnReduced;
solver.Solve(_puzzle);
SolverOnReduced(null, null);
if (_puzzle.IsSolved)
{
return;
}
if(_puzzle.HasErrors)
{
System.Console.WriteLine("Puzzle has Errors");
}
var tempPath = Path.GetTempPath();
string tempFileName;
do
{
tempFileName = Path.Combine(tempPath, Guid.NewGuid().ToString().Remove(8) + ".html");
} while (File.Exists(tempFileName));
File.WriteAllText(tempFileName, GetPuzzleHtml());
Process.Start(tempFileName);
}
示例14: LocatingThings
public void LocatingThings()
{
using (var browser =
new IE("http://www.pluralsight.com"))
{
//// Get a reference to a HTML input element, type=text, id=Name
//TextField applicantName = browser.TextField(Find.ById("Name"));
//// Get a reference to a HTML link element with id=HelpLink
//Link helpHyperlink = browser.Link(Find.ById("HelpLink"));
//// Get a reference to a HTML input element, type=submit, id=ApplyNow
//Button applyButton = browser.Button(Find.ById("ApplyNow"));
//// Get a reference to a HTML paragraph element, id=Name
//Para nameParagraph = browser.Para(Find.ById("Name"));
TextField applicantName = browser.TextField(Find.ById("Name"));
Link helpHyperlink = browser.Link(Find.ById("HelpLink"));
Button applyButton = browser.Button(Find.ById("ApplyNow"));
Para nameParagraph = browser.Para(Find.ById("Name"));
}
}
示例15: TestFixtureSetUp
public void TestFixtureSetUp()
{
browser = new IE(BuildUrl("Login", "Index"));
CompleteLoginForm(browser, "johnpolling", "password");
listPluginUrl = BuildUrl("Administrator", "Plugins", "List");
}