本文整理匯總了C#中WatiN.Core.IE.Button方法的典型用法代碼示例。如果您正苦於以下問題:C# IE.Button方法的具體用法?C# IE.Button怎麽用?C# IE.Button使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WatiN.Core.IE
的用法示例。
在下文中一共展示了IE.Button方法的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: 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"));
}
}
示例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: Should_add_three_visits
public void Should_add_three_visits()
{
new DatabaseTester().Clean();
var url = "http://localhost:1234/";
using (var ie = new IE(url))
{
ie.Button("submit").Click();
Thread.Sleep(2000);
ie.Button("submit").Click();
Thread.Sleep(2000);
ie.Button("submit").Click();
Thread.Sleep(2000);
ie.ElementsWithTag("hr").Count.ShouldEqual(3);
}
}
示例5: Login
protected void Login(IE ie)
{
TextField tf = ie.TextField(Find.ByName(t => t.EndsWith("$UserName")));
if (!tf.Exists) return; //already logged
tf.TypeText("Alkampfer");
ie.TextField(Find.ByName(t => t.EndsWith("$Password"))).TypeText("12345");
ie.Button(Find.ByName(b => b.EndsWith("$LoginButton"))).Click();
}
示例6: SearchForWatiNOnGoogle
public void SearchForWatiNOnGoogle()
{
using (var browser = new IE("http://www.google.com")) {
browser.TextField(Find.ByName("q")).TypeText("WatiN");
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText("WatiN"));
}
}
示例7: ClickMe
public void ClickMe()
{
IE ie = new IE("http://localhost/AnthemNxt.Tests/ButtonsAndLabels.aspx");
Assert.Null(ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text);
ie.Button(Find.ByName("ctl00$ContentPlaceHolder$button")).Click();
Assert.NotEqual("", ie.Span(Find.ById("ctl00_ContentPlaceHolder_label")).Text);
// TODO: Check no postback occurred - how can we do this?
ie.Close();
}
示例8: 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();
}
示例9: 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();
}
示例10: RunSmokeTest
public void RunSmokeTest()
{
using (var browser = new IE("http://www.google.com"))
{
const string search = "WatiN";
browser.TextField(Find.ByName("q")).TypeText(search);
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText(search));
}
}
示例11: HelloWatin
public void HelloWatin(string search)
{
using (var browser = new IE("http://www.google.com"))
{
browser.TextField(Find.ByName("q")).TypeText(search);
browser.Button(Find.ByName("btnG")).Click();
Assert.IsTrue(browser.ContainsText(search));
}
}
示例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: FillUS
public void FillUS()
{
using (var browser = new IE("http://www.eaa.org/eaa/eaa-membership/eaa-aircraft-insurance-plans/aircraft-insurance/insurance-submit-us"))
{
browser.AutoClose = false;
USPopulatePersonalInfoPage(browser);
browser.Button(Find.ById("main_0_eaamain_0_eaacontent_0_acmain_1_Quote_xQuoteWizard_StartNavigationTemplateContainerID_StartNextButton")).Click();
USPopulateAircraftPage(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();
USPopulateAircraftPage(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();
USPopulateAircraftPage(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();
USPopulatePilotPage(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();
USPopulatePilotPage(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();
USPopulatePilotPage(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();
}
}
示例14: Authorize
public Browser Authorize(string login, string password)
{
Browser browser = new IE("https://www.codeplex.com/site/login");
browser.GoTo("https://www.codeplex.com/site/login");
browser.Link("CodePlexLogin").Click();
browser.TextField("UserName").TypeText(login);
browser.TextField("Password").TypeText(password);
browser.Button("loginButton").Click();
return browser;
}
示例15: ResultWindow
public ResultWindow(int timeLimit , string idProblem)
: this()
{
this.timeLimit = timeLimit;
this.idProblem = idProblem;
Process process = new Process();
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "cmd";
process.StartInfo.Arguments =
string.Format("/C \"\"{0}\" < \"{1}\" > \"{2}\"\"",
Properties.Settings.Default.FileExec,
Properties.Settings.Default.FileInput,
Properties.Settings.Default.FileOutput);
process.Start();
if (!process.WaitForExit(timeLimit * 1000))
process.Kill();
if (process.ExitCode != 0)
{
runtime.Visibility = Visibility.Visible;
return;
}
timeExec.Content = process.TotalProcessorTime.Milliseconds / 1000f + "s";
try
{
textInput = File.ReadAllText(Properties.Settings.Default.FileInput);
textOutput = File.ReadAllText(Properties.Settings.Default.FileOutput);
textOutput = textOutput.Replace("\r\n", "\n");
//Settings.MakeNewIeInstanceVisible = false;
WatiN.Core.Settings.Instance.AutoMoveMousePointerToTopLeft = false;
browser = new IE(prefix + idProblem);
TextField inputField = browser.TextField(Find.ById("edit-input-data"));
WatiN.Core.Button buttonSubmit = browser.Button(Find.ById("edit-output"));
inputField.Value = textInput;
buttonSubmit.Click();
browser.WaitForComplete();
string result = browser.Html;
int begin = result.IndexOf("<pre>") + 5;
textCorrect = result.Substring(begin, result.IndexOf("</pre>") - begin);
File.WriteAllText(Properties.Settings.Default.FileCorrect, textCorrect);
if (textOutput != textCorrect)
incorrect.Visibility = Visibility.Visible;
else
accepted.Visibility = Visibility.Visible;
}
catch (Exception exception)
{
MessageBox.Show(exception.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
browser.ForceClose();
}