本文整理汇总了C#中WebPage.Close方法的典型用法代码示例。如果您正苦于以下问题:C# WebPage.Close方法的具体用法?C# WebPage.Close怎么用?C# WebPage.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebPage
的用法示例。
在下文中一共展示了WebPage.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HtmlInputButton_GetWithValueContainingWhitespace_Succeeds
public void HtmlInputButton_GetWithValueContainingWhitespace_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<input name=""inputName"" type=""submit"" value="" Search "" />
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
EnhancedHtmlInputButton button = window.Get<EnhancedHtmlInputButton>("Value= Search ");
//Act
button.Click();
window.Close();
}
}
示例2: GetChildren_UsingHyperlinks_CanFindHyperlinkByInnerText
public void GetChildren_UsingHyperlinks_CanFindHyperlinkByInnerText()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<div id=""div1"">
<a href=""#"">A - B - C</a>
<a href=""#"">A - F - E</a>
<a href=""#"">A - D - E</a>
<a href=""#"">Z - B - C</a>
<a href=""#"">Z - D - E</a>
</div>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
//Act
var collection = window.Get<EnhancedHtmlDiv>("id=div1").GetChildren();
foreach (var control in collection)
{
if (control is EnhancedHtmlHyperlink)
{
var link = (EnhancedHtmlHyperlink) control;
if (link.InnerText.StartsWith("A"))
{
Trace.WriteLine(string.Format("found: {0}", link.InnerText));
}
}
}
window.Close();
}
}
示例3: SelectItem_ByIndexOnHtmlComboBox_Succeeds
public void SelectItem_ByIndexOnHtmlComboBox_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<select id=""selectId"">
<option>Cricket</option>
<option>Football</option>
<option>Tennis</option>
</select>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
//Act
EnhancedHtmlComboBox comboBox = window.Get<EnhancedHtmlComboBox>("Id=selectId");
comboBox.SelectItem(1);
//Assert
Assert.AreEqual("Football", comboBox.SelectedItem);
window.Close();
}
}
示例4: Click_OnHtmlInputButtonWithEqualsSignInSearchParameterValue_Succeeds
public void Click_OnHtmlInputButtonWithEqualsSignInSearchParameterValue_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<input type=""submit"" value=""="" onclick=""alert('onclick');""/>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
EnhancedHtmlInputButton button = window.Get<EnhancedHtmlInputButton>("Value==");
//Act
button.Click();
window.PerformDialogAction(BrowserDialogAction.Ok);
window.Close();
}
}
示例5: LabelFor_OnHtmlLabel_Succeeds
public void LabelFor_OnHtmlLabel_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<form>
<label for=""male"">Male</label>
<input type=""radio"" name=""sex"" id=""male"" value=""male""><br>
<label for=""female"">Female</label>
<input type=""radio"" name=""sex"" id=""female"" value=""female""><br>
<label id=""other"" for=""other"">Other</label>
<input type=""radio"" name=""sex"" id=""other"" value=""other""><br>
<input type=""submit"" value=""Submit"">
</form>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
EnhancedHtmlLabel label = window.Get<EnhancedHtmlLabel>("id=other");
//Assert
Assert.AreEqual("other", label.LabelFor);
window.Close();
}
}
示例6: SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds
public void SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<select id=""selectId"" onchange=""alert('onchange');"">
<option>Apple</option>
<option>Banana</option>
<option>Carrot</option>
</select>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
EnhancedHtmlComboBox comboBox = window.Get<EnhancedHtmlComboBox>("Id=selectId");
//Act
comboBox.SelectItem("Banana");
window.PerformDialogAction(BrowserDialogAction.Ok);
window.Close();
}
}
示例7: SetText_OnHtmlEditWithOverlappedDiv_Succeeds
public void SetText_OnHtmlEditWithOverlappedDiv_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<div class=""textbox"" id=""idDiv_PWD_UsernameTb"" style=""margin-bottom: 8px;"">
<div style=""width: 100%; position: relative;"">
<input name=""login"" id=""i0116"" style=""ime-mode: inactive;"" type=""email"" maxLength=""113""/>
<div class=""phholder"" style=""left: 0px; top: 0px; width: 100%; position: absolute; z-index: 5;"">
<div class=""placeholder"" id=""idDiv_PWD_UsernameExample"" style=""cursor: text;"">
Text - [email protected]
</div>
</div>
</div>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var bWin = new WebPage("test");
EnhancedHtmlEdit txtUserName = bWin.Get<EnhancedHtmlEdit>("id=i0116");
//Act
txtUserName.SetText("hello");
//Assert
Assert.AreEqual("hello", txtUserName.GetText());
bWin.Close();
}
}
示例8: HtmlTable_GetColumnHeaders_Succeeds
public void HtmlTable_GetColumnHeaders_Succeeds()
{
WebPage.Launch(CurrentDirectory + "/TestHtmlPage.html");
var bWin = new WebPage("A Test");
EnhancedHtmlTable tbl = bWin.Get<EnhancedHtmlTable>("id=calcWithHeaders");
var saExpectedValues = new[] {"Header1", "Header2", "Header3"};
string[] saHeaders = tbl.GetColumnHeaders();
Assert.AreEqual(saExpectedValues[0], saHeaders[0]);
Assert.AreEqual(saExpectedValues[1], saHeaders[1]);
Assert.AreEqual(saExpectedValues[2], saHeaders[2]);
bWin.Close();
}
示例9: HtmlTable_FindHeaderAndClick_Succeeds
public void HtmlTable_FindHeaderAndClick_Succeeds()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<table style=""width: 100%;"" id=""tableId"">
<tbody>
<tr>
<td>Commitment</td>
<th>September</th>
<th>October</th>
<th>November</th>
<td>Total</td>
</tr>
<tr>
<td>Beginning Balance</td>
<td>¥21,570,253</td>
<td>¥21,375,491</td>
<td>¥21,200,873</td>
<td></td>
</tr>
<tr>
<td>New Purchases</td>
<td>¥0</td>
<td>¥0</td>
<td>¥0</td>
<td></td>
</tr>
<tr>
<td>Utilized</td>
<td>¥194,762</td>
<td>¥174,618</td>
<td>¥0</td>
<td>¥369,380</td>
</tr>
<tr>
<td>Ending Balance</td>
<td>¥21,375,491</td>
<td>¥21,200,873</td>
<td>¥21,200,873</td>
<td></td>
</tr>
<tr>
<td><b>Overage</b></td>
<td>¥0</td>
<td>¥0</td>
<td>¥0</td>
<td>¥0</td>
<td></td>
</tr>
<tr>
<td><b>Total Usage</b></td>
<td>¥194,762</td>
<td>¥174,618</td>
<td>¥0</td>
<td>¥369,380</td>
</tr>
</tbody>
</table>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
EnhancedHtmlTable table = window.Get<EnhancedHtmlTable>("id=tableId");
//Act
table.FindHeaderAndClick(0, 2);
window.Close();
}
}
示例10: GetHtmlDiv_ByClass_Succeeds
public void GetHtmlDiv_ByClass_Succeeds()
{
// Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<div class=""button""><a href=""/main"">main text</a></div>
<div class=""button""><a href=""/about"">about text</a></div>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
// Act
EnhancedHtmlDiv div = window.Get<EnhancedHtmlDiv>("class=button");
EnhancedHtmlHyperlink about = window.Get<EnhancedHtmlHyperlink>("InnerText=about text;href~about");
var div2 = about.Parent as EnhancedHtmlDiv;
// Assert
Assert.IsTrue(div.Exists);
Assert.AreEqual("main text", div.UnWrap().InnerText);
Assert.IsTrue(about.Exists);
Assert.IsTrue(div2.Exists);
Assert.AreEqual("about text", div2.UnWrap().InnerText);
window.Close();
}
}
示例11: GetHtmlRow_ById_Succeeds
public void GetHtmlRow_ById_Succeeds()
{
// Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<table class=""cart"" cellspacing=""0"">
<tbody>
<tr id=""555002_gp2"">
<td>
banana
</td>
</tr>
</tbody>
</table>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
// Act
EnhancedHtmlRow row = window.Get<EnhancedHtmlRow>("id=555002_gp2");
// Assert
Assert.IsTrue(row.Exists);
window.Close();
}
}
示例12: Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength
public void Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength()
{
// Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<input id=""input"" type=""text"" maxlength=10 />
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
EnhancedHtmlEdit input = window.Get<EnhancedHtmlEdit>("id=input");
// Act
string inputText = "12345678901";
string outputText = "1234567890";
Keyboard.SendKeys(input.UnWrap(), inputText);
// Assert
Assert.AreEqual(input.GetText(), outputText);
window.Close();
}
}
示例13: Launch_TempHtmlFile_CanFindHyperlinkByHref
public void Launch_TempHtmlFile_CanFindHyperlinkByHref()
{
// Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<div class=""login"" style=""border: none;"">
<div class=""member_box"">
<span>APPLY FOR MEMBERSHIP</span> <a href=""/registration""> </a>
</div>
</body>
</html>"))
{
// Act
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
// Assert
EnhancedHtmlHyperlink SignUpHyperLink = window.Get<EnhancedHtmlHyperlink>("href~registration");
Assert.IsTrue(SignUpHyperLink.Exists, "SignUp not found");
window.Close();
}
}
示例14: Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle
public void Launch_UsingNewInstanceOfABrowserWindow_CanUsePartialWindowTitle()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test 1 2 3</title>
</head>
<body>
<button id=""buttonId"" >Button</button>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
//Act
EnhancedHtmlButton button = window.Get<EnhancedHtmlButton>("id=buttonId");
//Assert
Assert.AreEqual(button.InnerText, "Button");
Trace.WriteLine(window.Uri.ToString());
window.Close();
}
}
示例15: HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle
public void HtmlButton_HiddenByStyle_ControlExistsAndCanAssertOnStyle()
{
//Arrange
using (var tempFile = new TempFile(
@"<html>
<head>
<title>test</title>
</head>
<body>
<button id=""buttonId"" style=""display: none;"" >Hidden</button>
</body>
</html>"))
{
WebPage.Launch(tempFile.FilePath);
var window = new WebPage("test");
//Act
EnhancedHtmlButton button = window.Get<EnhancedHtmlButton>("id=buttonId");
//Assert
Assert.IsTrue(button.Exists);
Assert.IsTrue(button.UnWrap().ControlDefinition.Contains("style=\"display: none;\""));
window.Close();
}
}