如何使用C在网格中运行Selenium测试#
我刚刚在我的本地机器上设置了selenium网格,一切似乎都正常运行 我的问题是,有没有一种方法可以从selenium网格节点(命令提示符)运行测试用例 我正在使用WebDriver使用.Net创建我的测试用例如何使用C在网格中运行Selenium测试#,selenium,selenium-webdriver,selenium-grid,Selenium,Selenium Webdriver,Selenium Grid,我刚刚在我的本地机器上设置了selenium网格,一切似乎都正常运行 我的问题是,有没有一种方法可以从selenium网格节点(命令提示符)运行测试用例 我正在使用WebDriver使用.Net创建我的测试用例 您所说的“有没有一种方法可以从selenium网格节点(命令提示符)运行测试用例?”是什么意思?那么让我问您,我们可以从selenium网格运行任何测试用例吗?我问的原因是我看到了youtube视频,他们在视频中使用python通过selenium网格运行测试用例。你可以通过网格运行任何
您所说的“有没有一种方法可以从selenium网格节点(命令提示符)运行测试用例?”是什么意思?那么让我问您,我们可以从selenium网格运行任何测试用例吗?我问的原因是我看到了youtube视频,他们在视频中使用python通过selenium网格运行测试用例。你可以通过网格运行任何selenium测试。该测试可以用Java Ruby Python编写(我认为C#也是如此)。但是你的问题是什么?我的问题是如何使用C#::)在网格中运行selenium测试。。。。有趣的是,我想我可以通过命令propmt运行测试用例
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
// Requires reference to WebDriver.Support.dll
using OpenQA.Selenium.Support.UI;
class GoogleSuggest
{
static void Main(string[] args)
{
// Create a new instance of the Firefox driver.
// Notice that the remainder of the code relies on the interface,
// not the implementation.
// Further note that other drivers (InternetExplorerDriver,
// ChromeDriver, etc.) will require further configuration
// before this example will work. See the wiki pages for the
// individual drivers at http://code.google.com/p/selenium/wiki
// for further information.
WebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.FirefoxDriver());
//Notice navigation is slightly different than the Java version
//This is because 'get' is a keyword in C#
driver.Navigate().GoToUrl("http://www.google.com/");
// Find the text input element by its name
IWebElement query = driver.FindElement(By.Name("q"));
// Enter something to search for
query.SendKeys("Cheese");
// Now submit the form. WebDriver will find the form for us from the element
query.Submit();
// Google's search is rendered dynamically with JavaScript.
// Wait for the page to load, timeout after 10 seconds
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
// Should see: "Cheese - Google Search"
System.Console.WriteLine("Page title is: " + driver.Title);
//Close the browser
driver.Quit();
}
}
WebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.FirefoxDriver());
OR in c#
IWebDriver driver;
DesiredCapabilities capability = new DesiredCapabilities();
driver = new RemoteWebDriver(
new Uri("http://hub-cloud.com/wd/hub/"), capability);
driver.Navigate().GoToUrl("http://www.google.com");