本文整理汇总了C#中OpenQA.Selenium.Chrome.ChromeDriver.Manage方法的典型用法代码示例。如果您正苦于以下问题:C# ChromeDriver.Manage方法的具体用法?C# ChromeDriver.Manage怎么用?C# ChromeDriver.Manage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Chrome.ChromeDriver
的用法示例。
在下文中一共展示了ChromeDriver.Manage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWebDriver
public IWebDriver CreateWebDriver()
{
var driver = new ChromeDriver(@"C:\SeGrid");
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
return driver;
}
示例2: StartDriver
public static IWebDriver StartDriver (string browserType)
{
Trace.WriteLine("Start browser: '" + browserType + "'");
IWebDriver driver = null;
switch (browserType)
{
case "ie":
{
driver = new InternetExplorerDriver("Drivers");
break;
}
case "firefox":
{
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.EnableNativeEvents = true;
firefoxProfile.AcceptUntrustedCertificates = true;
driver = new FirefoxDriver(firefoxProfile);
break;
}
case "chrome":
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArgument("--disable-keep-alive");
driver = new ChromeDriver("Drivers", chromeOptions);
break;
}
}
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
driver.Manage().Window.Maximize();
return driver;
}
示例3: InitDriver
public static IWebDriver InitDriver(IWebDriver driver)
{
driver = new ChromeDriver(driverPath);
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(100));
driver.Navigate().GoToUrl(Url);
return driver;
}
示例4: CreateWebDriver
public static void CreateWebDriver()
{
ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized");
driver = new ChromeDriver("../../Drivers", options, TimeSpan.FromSeconds(Timeout));
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(Timeout));
driver.Manage().Cookies.DeleteAllCookies();
driver.Url = URL;
}
示例5: BeforeTestRun
public static void BeforeTestRun()
{
ChromeOptions optionChrome = new ChromeOptions();
optionChrome.AddAdditionalCapability("chrome.noWebsiteTestingDefaults", false);
optionChrome.AddAdditionalCapability("chrome.applicationCacheEnabled", false);
Driver = new ChromeDriver();
Driver.Manage().Cookies.DeleteAllCookies();
Driver.Manage().Window.Maximize();
Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5));
}
示例6: CreateWebDriver
public IWebDriver CreateWebDriver()
{
var driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(15));
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(15));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
var _ngDriver = new NgWebDriver(driver);
//_ngDriver.IgnoreSynchronization = true;
return _ngDriver;
}
示例7: ChromeBrowser
public static IWebDriver ChromeBrowser()
{
IWebDriver driver;
driver = new ChromeDriver(@"../../Files");
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl(BaseURL);
return driver;
}
示例8: CreateChromeDriverAutoDownload
public static IWebDriver CreateChromeDriverAutoDownload(string downloadDirectory)
{
ChromeOptions opts = new ChromeOptions();
opts.AddUserProfilePreference("download.default_directory", downloadDirectory);
opts.AddUserProfilePreference("download.prompt_for_download", "false");
var ChromeDriver = new ChromeDriver(opts);
ChromeDriver.Manage().Timeouts().SetPageLoadTimeout(new TimeSpan(0, 1, 0));
ChromeDriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 1));
ChromeDriver.Manage().Window.Maximize();
return ChromeDriver;
}
示例9: Should_page_through_items_in_chrome
public void Should_page_through_items_in_chrome()
{
IWebDriver chromeDriver = new ChromeDriver(TestContext.CurrentContext.TestDirectory);
chromeDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
chromeDriver.Navigate().GoToUrl("http://localhost:1392/");
Login(chromeDriver);
chromeDriver.FindElement(By.LinkText("Orders")).Click();
for (int i = 0; i < 82; i++)
{
IWebElement nextButton = chromeDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));
nextButton.Click();
IWebElement pageCount = chromeDriver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));
int pageNumber = int.Parse(pageCount.GetAttribute("value"));
Assert.AreEqual(i + 2, pageNumber);
}
chromeDriver.FindElement(By.Id("LoginStatus1")).Click(); ;
chromeDriver.Quit();
}
示例10: Host
public Host()
{
// Hack
int retryCount = 3;
while (true)
{
try
{
var options = new ChromeOptions();
options.AddArguments("test-type");
var service = ChromeDriverService.CreateDefaultService(@"..\..\Scaffolding\WebDriver");
service.HideCommandPromptWindow = false;
WebDriver = new ChromeDriver(service, options);
WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
Page = new Page(WebDriver);
Page.GotoUrl("Home");
break;
}
catch
{
if (retryCount-- == 0)
throw;
}
}
}
示例11: GetData
//碳结圆钢价格行情
public static void GetData(string linkName, int marketId)
{
IWebDriver driver = new ChromeDriver();
try
{
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("http://www.mysteel.com/");
var userName = driver.FindElement(By.Name("my_username"));
userName.SendKeys("tx6215");
var password = driver.FindElement(By.Name("my_password"));
password.SendKeys("tx6215");
userName.Submit();
var steel = driver.FindElement(By.LinkText("结构钢"));
driver.Navigate().GoToUrl(steel.GetAttribute("href"));
Thread.Sleep(2000);
var carbonRound = driver.FindElement(By.LinkText("碳圆"));
driver.Navigate().GoToUrl(carbonRound.GetAttribute("href"));
Thread.Sleep(2000);
var date = DateTime.Now.Day + "日";
GetPage(driver, linkName, marketId);
}
finally
{
driver.Close();
driver.Quit();
}
}
示例12: HomepageLoads_CalendarIsReachable
public void HomepageLoads_CalendarIsReachable()
{
// Instantiate a new web driver to run the test
//Implicit Path (Default)
IWebDriver driver = new ChromeDriver();
//Explicit Path
//IWebDriver driver = new ChromeDriver("\\\\psf\\Home\\Documents\\GitHubVisualStudio\\imentor\\UnitTests\\");
// Instruct the driver to throw an error if it has to wait more than 5 seconds for retrieval, then go to URL
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
driver.Navigate().GoToUrl("https://imast.azurewebsites.net");
// To verify that the homepage is online and reachable, we save the url after navigating and check it
String HomeUrl = driver.Url;
Assert.AreEqual("https://imast.azurewebsites.net/#!/", HomeUrl);
// Our home page is the Listings page. Test that it has loaded by comparing the title element to "Listings"
String PrimaryHeader = driver.FindElement(By.ClassName("im-form-label")).Text;
Assert.AreEqual("Upcoming Events", PrimaryHeader);
// Our home page also has a collection of filters. Test that they have loaded by checking their text tags.
String FilterHeader = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[1]/div")).Text;
String FilterMath = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[2]/div/div[1]")).Text;
String FilterScience = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[3]/div/div")).Text;
String FilterHistory = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[4]/div/div")).Text;
String FilterReading = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[5]/div/div")).Text;
String FilterCompSci = driver.FindElement(By.XPath("//*[@id=\"main-content\"]/div/div/div/div/div[4]/div[1]/div/div[2]/div[2]/md-content/md-list/md-list-item[6]/div/div")).Text;
// Assert that all the text tags are correct.
Assert.AreEqual("Subjects", FilterHeader);
Assert.AreEqual("Math", FilterMath);
Assert.AreEqual("Science", FilterScience);
Assert.AreEqual("History", FilterHistory);
Assert.AreEqual("Reading", FilterReading);
Assert.AreEqual("Computer Science", FilterCompSci);
// Next we find the Calendar Button and click it to navigate to the Calendar
IWebElement CalendarButton = driver.FindElement(By.ClassName("glyphicon-calendar"));
CalendarButton.Click();
// To verify that the calendar loaded, we check the "today button"
String Today = driver.FindElement(By.ClassName("fc-today-button")).Text;
Assert.AreEqual("today", Today);
// Also verify the other calendar buttons, month, week, and day.
String Month = driver.FindElement(By.ClassName("fc-month-button")).Text;
Assert.AreEqual("month", Month);
String Week = driver.FindElement(By.ClassName("fc-basicWeek-button")).Text;
Assert.AreEqual("week", Week);
String Day = driver.FindElement(By.ClassName("fc-basicDay-button")).Text;
Assert.AreEqual("day", Day);
// End the test by closing the browser
driver.Close();
}
示例13: Should_page_through_items_in_chrome
public void Should_page_through_items_in_chrome()
{
IWebDriver driver = new ChromeDriver();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("http://localhost:1392/");
driver.FindElement(By.Id("login_UserName")).Clear();
driver.FindElement(By.Id("login_UserName")).SendKeys("Admin");
driver.FindElement(By.Id("login_Password")).Clear();
driver.FindElement(By.Id("login_Password")).SendKeys("testing");
driver.FindElement(By.Id("login_LoginButton")).Click();
driver.FindElement(By.LinkText("Orders")).Click();
for (int i = 0; i < 82; i++)
{
IWebElement nextButton = driver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_ImageButtonNext"));
nextButton.Click();
IWebElement pageCount = driver.FindElement(By.Id("ContentPlaceHolder1_GridView1_ctl00_TextBoxPage"));
int pageNumber = int.Parse(pageCount.GetAttribute("value"));
Assert.AreEqual(i +2 , pageNumber);
}
driver.FindElement(By.Id("LoginStatus1")).Click(); ;
driver.Quit();
}
示例14: Main
static void Main(string[] args)
{
var url = "https://qa-antigo.elefanteletrado.com.br/Account/Login";
var driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(url);
Thread.Sleep(2000);
var campoLogin = driver.FindElementById("name");
campoLogin.SendKeys("asdf");
Thread.Sleep(2000);
var botaoEntrar = driver.FindElementByCssSelector("input[type=submit][title='" + "Entrar" + "']");
botaoEntrar.Click();
Thread.Sleep(2000);
var mensagemInvalida = "Usuário não encontrado.";
var tagErro = driver.FindElementByClassName("error");
if (tagErro.Text != mensagemInvalida)
{
Console.WriteLine("Mensagem errada, veio: " + tagErro.Text + ", esperado: " + mensagemInvalida);
}
else
{
Console.WriteLine("Validação correta!");
}
}
示例15: 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;
}