本文整理匯總了C#中WatiN.Core.IE.ShowWindow方法的典型用法代碼示例。如果您正苦於以下問題:C# IE.ShowWindow方法的具體用法?C# IE.ShowWindow怎麽用?C# IE.ShowWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WatiN.Core.IE
的用法示例。
在下文中一共展示了IE.ShowWindow方法的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: SetUp
public void SetUp()
{
Settings.WaitForCompleteTimeOut = 10;
Settings.WaitUntilExistsTimeOut = 10;
ie = new IE();
ie.GoTo(url + "ProspectorPlus/VendorLogin.aspx");
ie.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
}
示例4: openThread_Click
private void openThread_Click(object sender, EventArgs e)
{
var browser = new IE("forums.wynncraft.com/threads/invasion-tracker.28/page-" + a.ToString());
browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
string post = "There will be a swarm on Server " + server.ToString() + " in " + city.ToString() + ". ";
if (mins != 0) { post += "It will be in " + mins.ToString() + " minutes time."; }
else { post += "I am unsure how long it is until it starts."; }
Clipboard.SetText(post);
}
示例5: RegisterStandardTestUser
/// <summary>
/// Registers the standard test user.
/// </summary>
/// <param name="browser">The <paramref name="browser"/> instance.</param>
/// <param name="userName">Name of the user.</param>
/// <param name="password">The password.</param>
/// <returns>
/// If User was Registered or not
/// </returns>
public static bool RegisterStandardTestUser(IE browser, string userName, string password)
{
browser.GoTo("{0}yaf_register.aspx".FormatWith(TestConfig.TestForumUrl));
var email = "{0}@test.com".FormatWith(userName.ToLower());
browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
// Check if Registrations are Disabled
if (browser.ContainsText("You tried to enter an area where you didn't have access"))
{
return false;
}
// Accept the Rules
if (browser.ContainsText("Forum Rules"))
{
browser.Button(Find.ById("forum_ctl04_Login1_LoginButton")).Click();
browser.Refresh();
}
if (browser.ContainsText("Security Image"))
{
return false;
}
// Fill the Register Page
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_UserName"))).TypeText(
userName);
if (browser.ContainsText("Display Name"))
{
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_DisplayName"))).TypeText(userName);
}
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Password"))).TypeText(password);
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_ConfirmPassword"))).TypeText(password);
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Email"))).TypeText(email);
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Question"))).TypeText(password);
browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_Answer"))).TypeText(password);
////browser.TextField(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_tbCaptcha"))).TypeText(captcha);
// Create User
browser.Button(Find.ById(new Regex("CreateUserWizard1_CreateUserStepContainer_StepNextButton"))).Click();
if (!browser.ContainsText("Forum Preferences"))
{
return false;
}
browser.Button(Find.ById(new Regex("ProfileNextButton"))).Click();
return browser.Link(Find.ById(new Regex("_LogOutButton"))).Exists;
}
示例6: NavigateToHomePage
public static void NavigateToHomePage(ref IE ieBrowser)
{
if (ieBrowser == null)
{
ieBrowser = new IE();
ieBrowser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
}
ieBrowser.GoTo(ConfigurationReader.getHomePageUrl() + "Default.aspx");
ieBrowser.WaitForComplete();
}
示例7: QUnitParser
/// <summary>
/// Default constructor.
/// </summary>
/// <param name="maxWaitInMs">The maximum number of milliseconds before the tests should timeout after page load; -1 for infinity, 0 to not support asynchronous tests</param>
public QUnitParser(int maxWaitInMs)
{
_maxWaitInMs = maxWaitInMs < 0 ? Int32.MaxValue : maxWaitInMs;
_ie = new IE();
if (NQUnit.HideBrowserWindow)
{
_ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
}
if (NQUnit.ClearCacheBeforeRunningTests)
{
_ie.ClearCache();
}
}
示例8: InteractingWithElement
public void InteractingWithElement()
{
using (var browser =
new IE("http://localhost:62727/Pages/ApplyForCreditCard.aspx"))
{
browser.AutoClose = false;
browser.ShowWindow(NativeMethods.WindowShowStyle.Minimize);
browser.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
TextField applicantName = browser.TextField(Find.ById("Name"));
applicantName.TypeText("Jason Roberts");
Link helpHyperlink = browser.Link(Find.ById("HelpLink"));
helpHyperlink.Click();
SelectList title = browser.SelectList(Find.ById("Title"));
title.Select("Prof");
title.SelectByValue("4");
Button applyButton = browser.Button(Find.ById("ApplyNow"));
applyButton.Click();
}
}
示例9: OpenIEInstance
/// <summary>
/// Opens a new IE instance with the given settings in front of other windows that are currently open.
/// </summary>
/// <param name="targetURL">The URL that the IE instance should browse to.</param>
/// <param name="silentMode">If true the test will be run without displaying any IE instance or steps.</param>
/// <param name="timeOut">The default time out to use when calling IE.AttachToIE(findby).</param>
/// <param name="autoCloseIE">If true when a reference to the IE instance is destroyed the actual window will close.</param>
/// <param name="movePointer">It true the mouse pointer will move to the top left corner of the screen when a new IE instance is created.</param>
/// <returns>The new IE instance.</returns>
public static IE OpenIEInstance(string targetURL, bool silentMode, int timeOut, bool autoCloseIE, bool movePointer)
{
Settings.MakeNewIeInstanceVisible = !silentMode;
Settings.WaitForCompleteTimeOut = timeOut;
Settings.WaitUntilExistsTimeOut = timeOut;
Settings.AttachToBrowserTimeOut = timeOut;
Settings.AutoMoveMousePointerToTopLeft = movePointer;
IE ieInstance = new IE { AutoClose = autoCloseIE };
if(!silentMode) ieInstance.ShowWindow(NativeMethods.WindowShowStyle.ShowMaximized);
ieInstance.BringToFront();
ieInstance.GoTo(targetURL);
return ieInstance;
}
示例10: SetUp
public void SetUp()
{
Settings.WaitForCompleteTimeOut = 80;
Settings.WaitUntilExistsTimeOut = 80;
platform = (Platform)Enum.Parse(typeof(Platform), System.Configuration.ConfigurationManager.AppSettings["Platform"]);
targetHost = System.Configuration.ConfigurationManager.AppSettings["TargetHost"];
switch (platform)
{
case Platform.IE:
browser = new IE();
browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
break;
case Platform.FF:
browser = new FireFox();
browser.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.Maximize);
break;
}
browser.GoTo(targetHost);
}
示例11: WatinDriver
public WatinDriver(IE ie, string baseurl)
{
_baseurl = baseurl;
IE = ie;
IE.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
}
示例12: GetInternetExplorer
public static IE GetInternetExplorer()
{
if (_browser == null)
{
lock (LOCK_ROOT)
{
if (_browser == null)
{
IE.Settings.AutoMoveMousePointerToTopLeft = false;
_browser = (IE) BrowserFactory.Create(BrowserType.InternetExplorer);
_browser.ShowWindow(NativeMethods.WindowShowStyle.Hide);
}
}
}
return _browser;
}
示例13: BeforeTest
public void BeforeTest()
{
Log = new TestContextLog(TestContext);
_ie = new IE();
_ie.ShowWindow(NativeMethods.WindowShowStyle.Hide);
}
示例14: WebApplicationScraping
public void WebApplicationScraping()
{
try
{
// Reads the path of the web application
string webSitePath = Convert.ToString(ConfigurationManager.AppSettings["WebApplicationPath"]);
string filePhysicalPath = Convert.ToString(ConfigurationManager.AppSettings["ScraperEnginePhysicalLocation"]);
StreamWriter file = new StreamWriter(filePhysicalPath + "Output.txt");
if (webSitePath != null && webSitePath != string.Empty)
{
// Create an instance of IE browser
IE ieInstance = new IE(webSitePath);
// This will opens IE browser in maximized mode
ieInstance.ShowWindow(WatiN.Core.Native.Windows.NativeMethods.WindowShowStyle.ShowMaximized);
// Watin window will not visible to the end user when web scraping is done
//ieInstance.Visible = false;
// This will wait for the browser to complete loading of the page
ieInstance.WaitForComplete();
// This will store page source in categoryPageSource variable
string categoryPageSource = ieInstance.Html;
// Regular expression pattern to fetch list of categories categories
Regex categoryMatches = new Regex(_categoryRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);
// Fetches all the categories based upon category regex from category listing page
MatchCollection categoryMatchCollection = categoryMatches.Matches(categoryPageSource);
// Navigate to each categories and fetch page URL and navigate to the item listing page for each categories
foreach (Match categoryMatch in categoryMatchCollection)
{
GroupCollection categoryGroup = categoryMatch.Groups;
// URL of the item listing page
string itemListingURL = Convert.ToString(categoryGroup["href"].Value);
// Partial web path where demonstration web site is deployed.
// Note: This path needs to be modified in App.Config file accordingly.
string webSiteHostedLocation = webSitePath.Remove(webSitePath.LastIndexOf("/"));
// Creates path of the category listing page.
string itemListingpath = webSiteHostedLocation + "/" + itemListingURL;
// Navigate to the item listing page
ieInstance.GoTo(itemListingpath);
ieInstance.WaitForComplete();
// HTML source of given generated web page
string itemListingPageSource = ieInstance.Html;
// Match for the paging Event
Regex pagingMatches = new Regex(_pagingRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant | RegexOptions.Multiline);
// Find Matches.
MatchCollection pagingMatchCollection = pagingMatches.Matches(itemListingPageSource);
foreach (Match pageMatch in pagingMatchCollection)
{
GroupCollection pagingGroup = pageMatch.Groups;
if (pagingGroup[_pageNumber].Value != "1")
{
// Fetches the page number of the current page.
string linkText = Convert.ToString(pagingGroup[_pageNumber].Value);
// Performs click event on the given link. For e.g if linkText contains "2" as a value then
//Watin will perform click event on this second link.
ieInstance.Link(Find.ByText(linkText)).Click();
// Wait for the operation to complete
ieInstance.WaitForComplete();
// Store the result of the page in itemListingPageSource variable
itemListingPageSource = ieInstance.Html;
}
Regex itemMatches = new Regex(_itemRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.CultureInvariant);
// Fetches all the items based upon item regex from the item listing page
MatchCollection itemMatchCollection = itemMatches.Matches(itemListingPageSource);
// Navigate to each item and fetch ProductID, ProductName and ProductPrice and store the result in text file
foreach (Match itemMatch in itemMatchCollection)
{
GroupCollection itemGroups = itemMatch.Groups;
// Fetch productId from the given item group
string productID = Convert.ToString(itemGroups[_productID].Value);
// Fetch productName from the given item Group
string productName = Convert.ToString(itemGroups[_productName].Value);
// Fetch product price from the given product price
//.........這裏部分代碼省略.........
示例15: SetupWebsite
/// <summary>
/// Setups the Test website.
/// </summary>
private void SetupWebsite()
{
IEInstance = new IE();
IEInstance.GoTo("{0}install/default.aspx".FormatWith(TestConfig.TestForumUrl));
IEInstance.ShowWindow(NativeMethods.WindowShowStyle.Maximize);
IEInstance.WaitForComplete(5000);
// Enter Config Password
IEInstance.TextField(Find.ById("InstallWizard_txtEnteredPassword")).TypeText(TestConfig.ConfigPassword);
IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepPreviousButton")).Click();
IEInstance.RadioButton(Find.ById("InstallWizard_rblYAFDatabase_1")).Click();
// Enter YAF Database Connection
IEInstance.TextField(Find.ById("InstallWizard_Parameter1_Value")).TypeText(TestConfig.DatabaseServer);
IEInstance.TextField(Find.ById("InstallWizard_Parameter2_Value")).TypeText(TestConfig.TestDatabase);
// Test Database Conncection
IEInstance.Button(Find.ById("InstallWizard_btnTestDBConnection")).Click();
Assert.IsTrue(IEInstance.ContainsText("Connection Succeeded"), "Database Connection Is Wrong");
IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
// Test Mail Setup
IEInstance.TextField(Find.ById("InstallWizard_txtTestFromEmail")).TypeText(TestConfig.TestForumMail);
IEInstance.TextField(Find.ById("InstallWizard_txtTestToEmail")).TypeText("[email protected]");
IEInstance.Button(Find.ById("InstallWizard_btnTestSmtp")).Click();
Assert.IsTrue(
IEInstance.ContainsText("Mail Sent. Verify it's received at your entered email address."),
"Mail Send Failed");
if (TestConfig.UseTestMailServer)
{
SmtpMessage mail = SmtpServer.ReceivedEmail[0];
Assert.AreEqual("[email protected]", mail.ToAddresses[0].ToString(), "Receiver does not match");
Assert.IsTrue(mail.FromAddress.ToString().Contains(TestConfig.TestForumMail), "Sender does not match");
Assert.AreEqual(
"Test Email From Yet Another Forum.NET", mail.Headers["Subject"], "Subject does not match");
Assert.AreEqual(
"The email sending appears to be working from your YAF installation.",
mail.MessageParts[0].BodyView,
"Body does not match");
}
// Now continue to Initialize Database
IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).Click();
// Initialize Database
IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).ClickNoWait();
IEInstance.WaitUntilContainsText("Create Board", 300);
Assert.IsTrue(IEInstance.ContainsText("Create Board"));
// Board Settings
IEInstance.TextField(Find.ById("InstallWizard_TheForumName")).TypeText(TestConfig.TestApplicationName);
IEInstance.TextField(Find.ById("InstallWizard_ForumEmailAddress")).TypeText(TestConfig.TestForumMail);
// Admin User
IEInstance.TextField(Find.ById("InstallWizard_UserName")).TypeText(TestConfig.AdminUserName);
IEInstance.TextField(Find.ById("InstallWizard_AdminEmail")).TypeText(TestConfig.TestForumMail);
IEInstance.TextField(Find.ById("InstallWizard_Password1")).TypeText(TestConfig.AdminPassword);
IEInstance.TextField(Find.ById("InstallWizard_Password2")).TypeText(TestConfig.AdminPassword);
IEInstance.TextField(Find.ById("InstallWizard_SecurityQuestion")).TypeText(TestConfig.AdminPassword);
IEInstance.TextField(Find.ById("InstallWizard_SecurityAnswer")).TypeText(TestConfig.AdminPassword);
IEInstance.Button(Find.ById("InstallWizard_StepNavigationTemplateContainerID_StepNextButton")).ClickNoWait();
IEInstance.WaitUntilContainsText("Setup/Upgrade Finished", 300);
Assert.IsTrue(IEInstance.ContainsText("Setup/Upgrade Finished"));
IEInstance.Button(Find.ById("InstallWizard_FinishNavigationTemplateContainerID_FinishButton")).ClickNoWait();
IEInstance.WaitUntilContainsText("Welcome Guest!", 300);
Assert.IsTrue(IEInstance.ContainsText("Welcome Guest!"), "Installation failed");
}