本文整理汇总了C#中IWebDriver.CloseCurrentTab方法的典型用法代码示例。如果您正苦于以下问题:C# IWebDriver.CloseCurrentTab方法的具体用法?C# IWebDriver.CloseCurrentTab怎么用?C# IWebDriver.CloseCurrentTab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebDriver
的用法示例。
在下文中一共展示了IWebDriver.CloseCurrentTab方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckCriteria
/// <summary>
/// Implements the test logic for checking if selected goods fulfill selected criteria
/// </summary>
/// <param name="driver"></param>
/// <param name="item"></param>
/// <param name="selected_criteria_set"></param>
public static void CheckCriteria(IWebDriver driver, IWebElement item, Dictionary<Enum, List<Enum>> selected_criteria_set)
{
//this is done so that we can get to a link that shall be opened in a new tab
IWebElement link_item = item.FindElement(By.ClassName("g-i-tile-i-title"));
link_item = link_item.FindElement(By.TagName("a"));
//and it shall be opened in a new tab
link_item.OpenLinkInNewTab(driver);
//and we navigate to that new tab which is to the right
driver.SwitchTabRight();
//Initialize the POM for the properties of the good
GoodTitlePage good_title_page = new GoodTitlePage(driver);
GoodPropertiesPage good_properties_page = good_title_page.OpenAllPropertiesPage(driver);
//we assume that goods properties match the criteria
bool properties_match = true;
//We break up the properties page into property-name-property-value pairs by a classname
ReadOnlyCollection<IWebElement> property_pairs =
good_properties_page.contProperties.FindElements(By.ClassName("pp-characteristics-tab-i"));
//And turn it into a dictionary
Dictionary<string, string> title_value_pairs = new Dictionary<string, string>();
foreach (IWebElement property_pair in property_pairs)
{
string title = property_pair.FindElement(By.ClassName("pp-characteristics-tab-i-title")).Text;
string value = property_pair.FindElement(By.ClassName("pp-characteristics-tab-i-field")).Text;
//by shoving title and value in it
title_value_pairs.Add(title, value);
}
//now for EACH criterion (cojunction)
foreach (Filters key in selected_criteria_set.Keys)
{
//if there was no such selected option that products values could fulfill then local_match is false and so is properties match from now on
properties_match = properties_match && AssertProperties(good_properties_page.txGoodTitle.Text, key, title_value_pairs, selected_criteria_set);
}
//finally we check if the properties did indeed match, that is if properties_match is true
Assert.IsTrue(properties_match);
//Lastly close current tab
driver.CloseCurrentTab();
}