本文整理匯總了C#中WatiN.Core.IE.Link方法的典型用法代碼示例。如果您正苦於以下問題:C# IE.Link方法的具體用法?C# IE.Link怎麽用?C# IE.Link使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WatiN.Core.IE
的用法示例。
在下文中一共展示了IE.Link方法的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: 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;
}
示例3: 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"));
}
}
示例4: Chat
private static void Chat(WebClient client, string path)
{
using (File.Create(path))
{
}
using (var browser = new IE("http://widget.chatvdvoem.ru/iframe?mode=production&height=600"))
{
browser.Link(Find.ById("chat_start")).Click();
var lastAnswer = string.Empty;
var answer = string.Empty;
while (true)
{
var i = 0;
while (string.Equals(lastAnswer, answer,
StringComparison.InvariantCultureIgnoreCase))
{
Thread.Sleep(7000);
i++;
if (i > 4)
{
browser.ForceClose();
return;
}
var froms = browser.Elements.Filter(p => p.ClassName == "messageFrom");
if (froms.Count == 0)
continue;
answer = froms.Last().Text;
answer = answer.Substring(6);
}
lastAnswer = answer;
if (BlackListed(answer))
break;
var question = GetAnswer(client, answer);
File.AppendAllLines(path, new[] { answer, question });
browser.TextField(Find.ByName("text")).TypeText(question);
Thread.Sleep(2000);
browser.Button(Find.ById("text_send")).Click();
}
browser.ForceClose();
}
}
示例5: BrowsingByGenreReturnsAlbumList
public void BrowsingByGenreReturnsAlbumList()
{
using (var browser = new IE("http://localhost:1200/"))
{
browser.Link(Find.ByText("Rock")).Click();
Assert.IsTrue(browser.List(Find.ById("album-list")).Children().Any());
}
}
示例6: Adding_Items_ToCart
public void Adding_Items_ToCart()
{
using (var browser = new IE())
{
browser.GoTo("http://localhost:1100/");
browser.BringToFront();
browser.Link(Find.ByText("Pop")).Click();
browser.Link(Find.ByText("Frank")).Click();
browser.Link(Find.ByText("Add to cart")).Click();
Assert.IsTrue(browser.ContainsText("8.99"));
}
}
示例7: SimpleJavaAlertHandler
public void SimpleJavaAlertHandler()
{
WatiN.Core.Settings.AutoMoveMousePointerToTopLeft = false;
WatiN.Core.Settings.MakeNewIeInstanceVisible = true;
using(WatiN.Core.IE ie = new IE(Path.Combine(System.Environment.CurrentDirectory, "testpage1.htm")))
{
ie.BringToFront();
Assert.AreEqual("Alert test", ie.Link("linkAlert").Text);
WatiN.Core.DialogHandlers.SimpleJavaDialogHandler handler = new SimpleJavaDialogHandler();
ie.DialogWatcher.Add(handler);
ie.Link("linkAlert").Click();
Assert.AreEqual("This is an alert message", handler.Message);
}
}
示例8: FillCA
public void FillCA()
{
using (var browser = new IE("http://www.eaa.org/eaa/eaa-membership/eaa-aircraft-insurance-plans/aircraft-insurance/insurance-submit-ca"))
//using (var browser = new IE("http://dev.eaa.org/eaa/eaa-membership/eaa-aircraft-insurance-plans/aircraft-insurance/insurance-submit-ca"))
{
browser.AutoClose = false;
CAPopulatePersonalInfoPage(browser);
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StartNavigationTemplateContainerID_StartNextButton")).Click();
CAPopulateAircraftPage(browser, "1");
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
// Add another aircraft
browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraftList_lnkAircraftAdd")).Click();
CAPopulateAircraftPage(browser, "2");
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraft_AddButton")).Click();
// Add another aircraft
browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraftList_lnkAircraftAdd")).Click();
CAPopulateAircraftPage(browser, "3");
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xAircraft_AddButton")).Click();
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
GenerateCode(browser);
CAPopulatePilotPage(browser, "1");
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilotList_lnkPilotAdd")).Click();
CAPopulatePilotPage(browser, "2");
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilot_AddButton")).Click();
browser.Link(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilotList_lnkPilotAdd")).Click();
CAPopulatePilotPage(browser, "3");
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_xPilot_AddButton")).Click();
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
// browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_FinishNavigationTemplateContainerID_FinishButton")).Click();
}
}
示例9: Should_update_product_price_successfully
public void Should_update_product_price_successfully()
{
using (var ie = new IE("http://localhost:8084/"))
{
ie.Link(Find.ByText("Products")).Click();
ie.Link(Find.ByText("Edit")).Click();
var priceField = ie.TextField(Find.ByName("Price"));
priceField.Value = "389.99";
ie.Button(Find.ByValue("Save")).Click();
ie.Url.ShouldEqual("http://localhost:8084/Product");
ie.ContainsText("389.99").ShouldBeTrue();
}
}
示例10: UploadVideo
public void UploadVideo(IE ie, string filePath)
{
ie.Link(Find.ById("uploadVideo")).Click();
var fu = ie.FileUpload(Find.ById("ctl00_cphAdmin_txtUploadVideo"));
fu.Set(filePath);
ie.Button(Find.ById("ctl00_cphAdmin_btnUploadVideo")).Click();
ie.WaitForComplete();
}
示例11: UploadImage
public void UploadImage(IE ie, string filePath)
{
ie.Link(Find.ById("uploadImage")).Click();
var fu = ie.FileUpload(Find.ByClass("ImageUpload"));
fu.Set(filePath);
ie.Button(Find.ById("ctl00_cphAdmin_btnUploadImage")).Click();
ie.WaitForComplete();
}
示例12: Check_That_When_Logged_In_As_Admin_Then_Add_Product_Works
public void Check_That_When_Logged_In_As_Admin_Then_Add_Product_Works()
{
var result = false;
using (IE netWindow = new IE("http://localhost:49573/default.aspx"))
{
LoginAsAdmin(netWindow);
netWindow.Link(Find.ById("ctl00_ucHeader_lnkAdminPage")).Click();
#region hidden new way
netWindow.Link(Find.ById(new Regex("AdminPage$")));
#endregion
netWindow.WaitForComplete();
netWindow.Button(Find.ById("ctl00_ucHeader_lnkProductAdmin")).Click();
netWindow.WaitForComplete();
netWindow.Button(Find.ById("ctl00_ContentPlaceHolder1_RadDock1_C_btnAddProduct")).Click();
netWindow.WaitForComplete();
netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductName")).TypeText(String.Format("Paul Test Product {0}", DateTime.Now.Ticks.ToString()));
netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlProductManufacturer")).SelectByValue("3");
netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlCategoryList")).SelectByValue("2");
netWindow.WaitForComplete(100);
netWindow.SelectList(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ddlSubCategoryList")).SelectByValue("2");
netWindow.WaitForComplete();
netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnAddCombo")).Click();
netWindow.WaitForComplete();
netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductPrice")).TypeText("19.99");
netWindow.TextField(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_txtProductModel")).TypeText("Paul Test Model 1");
netWindow.Link(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_btnSave")).Click();
netWindow.WaitForComplete();
Span resultMessage = netWindow.Span(Find.ById("ctl00_ContentPlaceHolder1_ucProduct_ucMessage_lblMessage"));
if (resultMessage.Text == "New Product created successfuly")
{
result = true;
}
}
Assert.IsTrue(result);
}
開發者ID:stack72,項目名稱:SpecFlow-Demo-Project-with-MVC-Music-Store,代碼行數:42,代碼來源:SampleTestsforWebforms.cs
示例13: LogOffAction
private void LogOffAction(string username, string password)
{
using (var browser = new IE(BuildUrl("Login", "Index")))
{
CompleteLoginForm(browser, username, password);
browser.Link("LogOff").Click();
Assert.AreEqual(BuildBaseUrl(), browser.Url);
}
}
示例14: RemoveItemsFromCart
public void RemoveItemsFromCart()
{
using (var browser = new IE())
{
browser.GoTo("http://localhost:1100/");
browser.BringToFront();
browser.Link(Find.ByText("Pop")).Click();
browser.Link(Find.ByText("Frank")).Click();
browser.Link(Find.ByText("Add to cart")).Click();
browser.Link(Find.BySelector("a.RemoveLink")).Click();
Assert.IsTrue(browser.ContainsText("0"));
}
}
示例15: Should_be_able_to_edit_conference
public void Should_be_able_to_edit_conference()
{
using (var ie = new IE("http://localhost:8084"))
{
var conferencesLink = ie.Link(Find.ByText("Conferences"));
conferencesLink.Click();
var editCodeMashLink = ie.Link(Find.ByText("Edit"));
editCodeMashLink.Click();
var nameBox = ie.TextField(Find.ByName("Name"));
nameBox.TypeText("CodeMashFoo");
var submitBtn = ie.Button(Find.ByValue("Save"));
submitBtn.Click();
ie.Url.ShouldEqual("http://localhost:8084/Conference");
ie.ContainsText("CodeMashFoo").ShouldBeTrue();
}
}