本文整理汇总了C#中OpenQA.Selenium.IE.InternetExplorerDriver.Manage方法的典型用法代码示例。如果您正苦于以下问题:C# InternetExplorerDriver.Manage方法的具体用法?C# InternetExplorerDriver.Manage怎么用?C# InternetExplorerDriver.Manage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.IE.InternetExplorerDriver
的用法示例。
在下文中一共展示了InternetExplorerDriver.Manage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWebDriver
public IWebDriver CreateWebDriver()
{
var driver = new InternetExplorerDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
return driver;
}
示例2: ConfigureDriver
public static IWebDriver ConfigureDriver(IWebDriver driver, string driverType, string driverPath)
{
switch (driverType)
{
case "ie":
{
driver = new InternetExplorerDriver(driverPath);
driver.Manage().Window.Maximize();
return driver;
}
case "firefox":
{
driver = new FirefoxDriver();
driver.Manage().Window.Maximize();
return driver;
}
case "chrome":
{
driver = new ChromeDriver(driverPath);
driver.Manage().Window.Maximize();
return driver;
}
}
return driver;
}
示例3: Should_page_through_items_in_IE
public void Should_page_through_items_in_IE()
{
IWebDriver ieDriver = new InternetExplorerDriver();
ieDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
ieDriver.Navigate().GoToUrl("http://localhost:1392/");
Login(ieDriver);
ieDriver.FindElement(By.LinkText("Orders")).Click();
for (int i = 0; i < 20; i++)
{
IWebElement nextButton = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));
nextButton.Click();
IWebElement pageCount = ieDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));
int pageNumber = int.Parse(pageCount.GetAttribute("value"));
Assert.AreEqual(i + 2, pageNumber);
}
ieDriver.FindElement(By.Id("LoginStatus1")).Click();
ieDriver.Quit();
}
示例4: IntializeDriver
internal void IntializeDriver(ref IWebDriver driver, ref bool IsBrowserDimendion, ref List<IWebDriver> driverlist, ref int width, ref int height,ref bool DeleteCookie)
{
InternetExplorerOptions options = new InternetExplorerOptions();
// Commented to check CSA related problem
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.EnablePersistentHover = false; //added for IE-8 certificate related issue.
if (DeleteCookie)
{
options.EnsureCleanSession = true;
}
driver = new InternetExplorerDriver(Property.ApplicationPath + @"\Exes", options);
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(150));
driver.Manage().Window.Maximize(); // Added to maximize IE window forcibely, as this code is updated Action file.
if (IsBrowserDimendion)
driver.Manage().Window.Size = new System.Drawing.Size(width, height);
driverlist.Add(driver);
}
示例5: getIEDriver
public static IWebDriver getIEDriver()
{
DriverFactory.DeleteIECookiesAndData();
InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IWebDriver driver = new InternetExplorerDriver(options);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(waitsec));
return driver;
}
示例6: Create
public IWebDriver Create()
{
if (browserType == Type)
{
var profileIE = new InternetExplorerOptions();
profileIE.EnableNativeEvents = true;
var browser = new InternetExplorerDriver(profileIE);
browser.Manage().Cookies.DeleteAllCookies();
return browser;
}
return null;
}
示例7: CreateWebDriver
private static IWebDriver CreateWebDriver()
{
var options = new InternetExplorerOptions
{
// This setting is used to ignore the requirement that protected mode must
// be set the same for all modes
// See: https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_Configuration
IntroduceInstabilityByIgnoringProtectedModeSettings = true
};
var driverPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var driver = new InternetExplorerDriver(driverPath, options);
// Configure the driver to wait up to 3 seconds for elements to appear
driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 0, 3));
return driver;
}
示例8: SelectBrowser
/// <summary>
/// BROWSER_TYPEの値によって起動するブラウザを変える
/// (firefox以外は不安定)
/// </summary>
/// <param name="webDriver"></param>
public static void SelectBrowser(ref IWebDriver webDriver)
{
switch (AppConfig.GetString(Config.BROWSER_TYPE))
{
case "1": // FireFox
FirefoxBinary firefoxBinary = new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe");
FirefoxProfile firefoxProfile = new FirefoxProfile();
webDriver = new FirefoxDriver(firefoxBinary, firefoxProfile);
break;
case "2": // Chrome
webDriver = new ChromeDriver();
break;
case "3": // IE
// ブラウザのズームレベルを100%にしないと落ちる
webDriver = new InternetExplorerDriver();
break;
default:
throw new OriginalException("BROWSER_TYPEが不正です。1~3の間で設定してください。");
}
webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
webDriver.Url = AppConfig.GetString(Config.TEST_URL);
}
示例9: IEDriverSetUp
public static InternetExplorerDriver IEDriverSetUp()
{
Action ensureDriverExists =
() =>
{
const string ieDriverExe = "IEDriverServer.exe.exe";
var fullPath = DriversFolder.pathCombine(ieDriverExe);
var is64BitOperatingSystem = Environment.Is64BitOperatingSystem;
if (fullPath.fileExists().isFalse())
{
var downloadUrl = is64BitOperatingSystem ? IEDriverDownloadLinkx64 : IEDriverDownloadLinkx32;
var downloadedZipFile = downloadUrl.download();
downloadedZipFile.unzip_File(DriversFolder);
}
};
Action configureEnvironmentPath =
() =>
{
var currentEnvironmentPath = Environment.GetEnvironmentVariable("Path");
if (currentEnvironmentPath.contains(DriversFolder).isFalse())
{
var newEnvironmentPath = "{0};{1}".info(currentEnvironmentPath, DriversFolder);
"Setting Environment Path to: {0}".format(newEnvironmentPath);
Environment.SetEnvironmentVariable("Path", newEnvironmentPath);
}
else
"Environment Path already had: {0}".info(DriversFolder);
};
ensureDriverExists();
configureEnvironmentPath();
var IEDriver = new InternetExplorerDriver();
IEDriver.Manage().Cookies.DeleteAllCookies();
return IEDriver;
}
示例10: InitializeInstalledBrowserDriver
/// <summary>
/// Gets the web driver for locally installed browsers.
/// </summary>
/// <param name="testSettings">The test settings.</param>
/// <param name="testOutputHelper">The test output helper.</param>
/// <returns></returns>
/// <exception cref="TestConfigurationException">The details you specified are invalid</exception>
/// <exception cref="TestConfigurationException">The details you specified are invalid</exception>
public static ITestWebDriver InitializeInstalledBrowserDriver(TestSettings testSettings,
ITestOutputHelper testOutputHelper)
{
ScreenShotCounter = 0;
TestOutputHelper = testOutputHelper;
testSettings = ValidateSavePaths(testSettings);
switch (testSettings.DriverType)
{
case WebDriverType.ChromeDriver:
{
string driverLocation = Path.Combine(AssemblyDirectory, "chromedriver.exe");
driverLocation = ValidateDriverPresentOrUnblocked(WebDriverType.ChromeDriver, driverLocation);
testSettings.BrowserName = "Chrome";
var driverService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation),
Path.GetFileName(driverLocation));
var options = new ChromeOptions
{
LeaveBrowserRunning = false
};
options.AddArgument("--no-default-browser-check");
options.AddArgument("--test-type=browser");
options.AddArgument("--start-maximized");
options.AddArgument("--allow-no-sandbox-job");
options.AddArgument("--disable-component-update");
options.AddArgument("--auth-server-whitelist=" + testSettings.TestUri.Authority.Replace("www", "*"));
var driver = new ChromeDriver(driverService, options, testSettings.TimeoutTimeSpan);
var firingDriver = AttachDriverEvents(driver);
if (testSettings.DeleteAllCookies)
{
firingDriver.Manage().Cookies.DeleteAllCookies();
}
driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan);
if (testSettings.MaximiseBrowser)
{
firingDriver.Manage().Window.Maximize();
}
var extendedWebDriver = new TestWebDriver(firingDriver, testSettings, TestOutputHelper);
TestWebDriver = extendedWebDriver;
return extendedWebDriver;
}
case WebDriverType.FirefoxDriver:
{
testSettings.BrowserName = "Firefox";
string winePath =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\Drivers\\FirefoxDrivers\\wires-0.6.2-win\\";
var driverService = FirefoxDriverService.CreateDefaultService(winePath);
//var driverService = FirefoxDriverService.CreateDefaultService();
var options = new FirefoxOptions();
options.IsMarionette = true;
var driver = new FirefoxDriver(driverService, options, testSettings.TimeoutTimeSpan);
if (testSettings.DeleteAllCookies)
{
driver.Manage().Cookies.DeleteAllCookies();
}
driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan);
if (testSettings.MaximiseBrowser)
{
driver.Manage().Window.Maximize();
}
var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper);
TestWebDriver = extendedWebDriver;
return extendedWebDriver;
}
case WebDriverType.InternetExplorerDriver:
{
testSettings.BrowserName = "IE";
var driverName = "IEDriverServer.exe";
if (Environment.Is64BitProcess)
{
driverName = "IEDriverServer64.exe";
}
string driverLocation = Path.Combine(AssemblyDirectory, driverName);
driverLocation = ValidateDriverPresentOrUnblocked(WebDriverType.InternetExplorerDriver,
driverLocation);
var driverService =
InternetExplorerDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation),
Path.GetFileName(driverLocation));
var options = new InternetExplorerOptions
{
IgnoreZoomLevel = true,
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
BrowserAttachTimeout = testSettings.TimeoutTimeSpan,
RequireWindowFocus = true,
ElementScrollBehavior = InternetExplorerElementScrollBehavior.Bottom,
InitialBrowserUrl = testSettings.TestUri.AbsoluteUri,
EnsureCleanSession = true,
EnableNativeEvents = true
};
var driver = new InternetExplorerDriver(driverService, options, testSettings.TimeoutTimeSpan);
if (testSettings.DeleteAllCookies)
{
//.........这里部分代码省略.........
示例11: InitializeStandaloneBrowserDriver
/// <summary>
/// Gets the web driver for standalone browsers.
/// </summary>
/// <param name="testSettings">The test settings.</param>
/// <param name="browserVersion">The browser version.</param>
/// <param name="testOutputHelper">The test output helper.</param>
/// <returns></returns>
public static ITestWebDriver InitializeStandaloneBrowserDriver(TestSettings testSettings, decimal browserVersion,
ITestOutputHelper testOutputHelper)
{
ScreenShotCounter = 0;
TestOutputHelper = testOutputHelper;
testSettings = ValidateSavePaths(testSettings);
switch (testSettings.DriverType)
{
case WebDriverType.ChromeDriver:
{
string driverLocation;
switch (browserVersion.ToString(CultureInfo.InvariantCulture))
{
case "48":
case "47":
case "46":
case "45":
case "44":
case "43":
driverLocation =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\Drivers\\ChromeDrivers\\2.20\\chromedriver.exe";
break;
case "42":
case "41":
case "40":
case "39":
driverLocation =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\Drivers\\ChromeDrivers\\2.14\\chromedriver.exe";
break;
case "38":
case "37":
case "36":
driverLocation =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\Drivers\\ChromeDrivers\\2.11\\chromedriver.exe";
break;
case "35":
case "34":
case "33":
driverLocation =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\Drivers\\ChromeDrivers\\2.10\\chromedriver.exe";
break;
case "32":
case "31":
case "30":
driverLocation =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\Drivers\\ChromeDrivers\\2.8\\chromedriver.exe";
break;
default:
driverLocation = Path.Combine(AssemblyDirectory, "chromedriver.exe");
break;
}
ValidateDriverPresentOrUnblocked(WebDriverType.ChromeDriver, driverLocation);
testSettings.BrowserName = "Chrome " + browserVersion;
var multiBrowserExe =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
"\\MultiBrowser\\MB_Chrome" + browserVersion + ".exe";
var driverService = ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(driverLocation),
Path.GetFileName(driverLocation));
var options = new ChromeOptions
{
LeaveBrowserRunning = false,
BinaryLocation = multiBrowserExe
};
options.AddArgument("--no-default-browser-check");
options.AddArgument("--test-type=browser");
options.AddArgument("--start-maximized");
options.AddArgument("--allow-no-sandbox-job");
options.AddArgument("--disable-component-update");
options.AddArgument("--auth-server-whitelist=" + testSettings.TestUri.Authority.Replace("www", "*"));
var driver = new ChromeDriver(driverService, options, testSettings.TimeoutTimeSpan);
if (testSettings.DeleteAllCookies)
{
driver.Manage().Cookies.DeleteAllCookies();
}
driver.Manage().Timeouts().ImplicitlyWait(testSettings.TimeoutTimeSpan);
if (testSettings.MaximiseBrowser)
{
driver.Manage().Window.Maximize();
}
var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper);
TestWebDriver = extendedWebDriver;
return extendedWebDriver;
}
case WebDriverType.FirefoxDriver:
{
testSettings.BrowserName = "Firefox " + browserVersion;
var multiBrowserExe =
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
//.........这里部分代码省略.........
示例12: TestBookSearch
public void TestBookSearch()
{
//First step is browse to website and go to search page.
System.IO.File.WriteAllText("result.txt","");
driver = new InternetExplorerDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("paratabplus.cloudapp.net");
driver.FindElementByClassName("menulist").FindElement(By.CssSelector("li a[href=\"/BookSearch/\"]")).Click();
Assert.AreEqual("Search", driver.Title);
IWebElement form;
//-----------------------------------
/* Next step is find book from define keywords then submit
* measure time from result that display in grey character on find result(if search result is found.)
* record it and use these measure data to summarize.
*/
driver.FindElementByName("Keyword").Clear();
driver.FindElementByName("Keyword").SendKeys("COM-FL2-2812");
driver.FindElementByTagName("select").Click();
driver.Keyboard.SendKeys(Keys.Down);
driver.Keyboard.SendKeys(Keys.Enter);
form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
form.Submit();
AssertSearchResult("Call no:COM-FL2-2812");
driver.FindElementByName("Keyword").Clear();
driver.FindElementByName("Keyword").SendKeys("Computer");
driver.FindElementByTagName("select").Click();
driver.Keyboard.SendKeys(Keys.Down);
driver.Keyboard.SendKeys(Keys.Enter);
form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
form.Submit();
AssertSearchResult("Bookname:Computer");
driver.FindElementByName("Keyword").Clear();
driver.FindElementByName("Keyword").SendKeys("James");
driver.FindElementByTagName("select").Click();
driver.Keyboard.SendKeys(Keys.Down);
driver.Keyboard.SendKeys(Keys.Enter);
form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
form.Submit();
AssertSearchResult("Author:James");
driver.FindElementByName("Keyword").Clear();
driver.FindElementByName("Keyword").SendKeys("shogakukan");
driver.FindElementByTagName("select").Click();
driver.Keyboard.SendKeys(Keys.Down);
driver.Keyboard.SendKeys(Keys.Enter);
form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
form.Submit();
AssertSearchResult("Publisher:shogakukan");
driver.FindElementByName("Keyword").Clear();
driver.FindElementByName("Keyword").SendKeys("1995");
driver.FindElementByTagName("select").Click();
driver.Keyboard.SendKeys(Keys.Down);
driver.Keyboard.SendKeys(Keys.Enter);
form = driver.FindElementByCssSelector("form[action=\"/BookSearch/Basic\"]");
form.Submit();
AssertSearchResult("Year:1995");
//-----------------------------------
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("NOV");
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Sword Art Online Aincrad");
driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("Reki Kawahara");
driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").SendKeys("Zenshu");
driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
AssertSearchResult("\r\nCall no:NOV\r\nBookname:Sword Art Online Aincrad\r\nAuthor:Reki Kawahara\r\n" +
"Publisher:Zenshu\r\nYear:null");
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("PE-FL1-0005");
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Football training");
driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("Graham Taylor");
driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").SendKeys("Leopard Books");
driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").SendKeys("1995");
driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
AssertSearchResult("\r\nCall no:PE-FL1-0005\r\nBookname:Football training\r\nAuthor:Graham Taylor\r\n" +
"Publisher:Leopard Books\r\nYear:1995");
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("MAT");
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("Theory of computation");
driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Author\"]").SendKeys("รศ.ดร.เกียรติกูล เจียรนัยธนะกิจ");
driver.FindElementByCssSelector("form input[placeholder=\"Publisher\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Year\"]").SendKeys("2009");
driver.FindElementByCssSelector("form[action=\"/BookSearch/Advance\"] input[type=\"submit\"]").Click();
AssertSearchResult("\r\nCall no:MAT\r\nBookname:Theory of computation\r\nAuthor:รศ.ดร.เกียรติกูล เจียรนัยธนะกิจ\r\n" +
"Publisher:null\r\nYear:2009");
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").Clear();
driver.FindElementByCssSelector("input[type=\"text\"][name=\"CallNumber\"]").SendKeys("NOV");
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").Clear();
driver.FindElementByCssSelector("form input[placeholder=\"Book name\"]").SendKeys("นิทาน");
//.........这里部分代码省略.........
示例13: IETest
public virtual void IETest()
{
if (!NareshScalerSettings.Default.IEEnabled)
return;
var driverDir = GetDriverDirectory();
try
{
IEDriver = new InternetExplorerDriver(driverDir);
}
catch (Exception)
{
// Only for master build
var masterLibDir = LocateDir(Directory.GetCurrentDirectory(), "lib");
IEDriver = new InternetExplorerDriver(masterLibDir);
}
IEDriver.Manage().Timeouts().ImplicitlyWait(DefaultTimeOutValue);
try
{
RunSeleniumTests(IEDriver);
}
catch (Exception e)
{
RecordError(IEDriver, CurrentlyRunningTest, e);
throw;
}
}
示例14: Actions
static Actions()
{
Driver = new InternetExplorerDriver();
Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
}
示例15: factoryMethod
public override IWebDriver factoryMethod()
{
driver = new InternetExplorerDriver();
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10));
return driver;
}