本文整理汇总了C#中OpenQA.Selenium.Chrome.ChromeDriver.Navigate方法的典型用法代码示例。如果您正苦于以下问题:C# ChromeDriver.Navigate方法的具体用法?C# ChromeDriver.Navigate怎么用?C# ChromeDriver.Navigate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Chrome.ChromeDriver
的用法示例。
在下文中一共展示了ChromeDriver.Navigate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Login
public void Login(String loginUrl)
{
var options = new ChromeOptions();
options.AddArguments("--test-type", "--start-maximized");
options.AddArguments("--test-type", "--ignore-certificate-errors");
options.BinaryLocation = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
driver = new ChromeDriver("C:\\Program Files (x86)\\Google\\Chrome\\Application", options);
driver.Navigate().GoToUrl(loginUrl);
int timeout = 0;
while (driver.FindElements(By.ClassName("logbox")).Count == 0 && timeout < 500)
{
Thread.Sleep(1);
timeout++;
}
IWebElement element = driver.FindElement(By.ClassName("logbox"));
IWebElement ElName = element.FindElement(By.Name("username"));
ElName.Clear();
ElName.SendKeys(loginName);
IWebElement ElPassword = element.FindElement(By.Id("password"));
ElPassword.Clear();
ElPassword.SendKeys(loginPassword);
IWebElement ElLogin = element.FindElement(By.Id("IBtnLogin"));
ElLogin.Click();
}
示例2: Index
public ActionResult Index()
{
var driver = new ChromeDriver();
//driver.Navigate().GoToUrl("http://diesel.elcat.kg");
driver.Navigate().GoToUrl("http://diesel.elcat.kg/index.php?act=Login");
// Get the page elements
var userNameField = driver.FindElementByName("UserName");
var userPasswordField = driver.FindElementByName("PassWord");
var loginButton = driver.FindElementByXPath("//input[@name='submit']");
// Type user name and password
userNameField.SendKeys("bishkek312");
userPasswordField.SendKeys("8061");
// and click the login button
loginButton.Click();
driver.Navigate().GoToUrl("http://diesel.elcat.kg/index.php?showtopic=43884872");
DeleteLastUp(driver);
var messageField = driver.FindElementById("fast-reply_textarea");
messageField.SendKeys(upMessageValue);
var sendButton = driver.FindElementByXPath("//input[@value='Отправить']");
return new EmptyResult();
//return View();
}
示例3: 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();
}
}
示例4: Scrape
private IEnumerable<Domain.Product> Scrape(string postcode)
{
var output = new List<Domain.Product>();
using (var driver = new ChromeDriver())
{
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
driver.Navigate().GoToUrl("http://www.dominos.co.uk");
driver.FindElementById("txtPostcode").SendKeys(postcode);
driver.FindElementById("btnStoreSearch").Click();
Thread.Sleep(1000);
driver.FindElementByCssSelector(".btn-secondary").Click();
Thread.Sleep(1000);
driver.Navigate().GoToUrl("https://www.dominos.co.uk/ProductCatalog/GetStoreContext");
string storeContextJson = driver.FindElementByTagName("pre").Text;
var storeContext = JsonConvert.DeserializeObject<StoreContext>(storeContextJson);
driver.Navigate().GoToUrl(
$"https://www.dominos.co.uk/ProductCatalog/GetStoreCatalog?collectionOnly={storeContext.SessionContext.CollectionOnly}&menuVersion={storeContext.SessionContext.MenuVersion}&storeId={storeContext.SessionContext.StoreId}");
string storeCatalogJson = driver.FindElementByTagName("pre").Text;
var products = JsonConvert.DeserializeObject<List<DTOs.Category>>(storeCatalogJson);
output = products
.SelectMany(p => p.Subcategories)
.SelectMany(p => p.Products)
.Where(p => !p.IsAlcohol)
.Where(p => p.Type != "PizzaLegend")
.Where(p => p.Name != "Half & Half")
.Where(p => p.Name != "Create Your Own")
.Select(p => new Domain.Product()
{
Id = p.Id.ToString(),
Name = p.Name,
Description = p.Description,
ImageUrl = p.ImageUrl.Replace("256x256", "1024x1024"),
GlutenFree = p.IsGlutenFree,
Hot = p.IsHot,
Vegetarian = p.IsVegetarian,
Price = p.DisplayPrice,
Category = (ProductCategory)Enum.Parse(typeof(ProductCategory), p.Type)
})
.ToList();
}
return output;
}
示例5: RunSolution
public void RunSolution()
{
using (var driver = new ChromeDriver())
{
driver.Navigate().GoToUrl(ULearnUrls.StartPage);
UlearnDriver ulearnDriver = new UlearnDriver(driver);
ulearnDriver.LoginAdminAndGoToCourse(Titles.BasicProgrammingTitle);
driver.Navigate().GoToUrl("https://localhost:44300/Course/BasicProgramming/Slide/21");
}
}
示例6: Main
private static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver("C:\\");
driver.Navigate().GoToUrl("file:///C:/Users/anil.krishnamaneni/Desktop/New%20Text%20Document.html");
var coll = driver.FindElements(By.TagName("label"));
foreach (var label in coll)
{
if (label.Text.Trim() == "welcome to Ding")
{
label.Click();
break;
}
}
var alert = driver.WaitGetAlert();
IAlert a = driver.SwitchTo().Alert();
a.Accept();
driver.FindElement(By.TagName("Input")).Click();
a = driver.SwitchTo().Alert();
a.Accept();
driver.FindElement(By.ClassName("submit")).Click();
a = driver.SwitchTo().Alert();
a.Accept();
}
示例7: Register
public static void Register(BackgroundWorker worker, string name, string password, IList<string> barcodes)
{
driver = new ChromeDriver();
driver.Navigate().GoToUrl("https://7777.bg/user/lottery_tickets/register/");
driver.FindElementByName("login_username").SendKeys(name);
driver.FindElementByName("login_password").SendKeys(password);
driver.FindElementByXPath("//input[@type='submit']").Click();
Wait(driver);
var barcodeTextBox = driver.FindElementByName("register_number");
var submitButton = driver.FindElementByXPath("//button[@type='submit']");
int progressPercentage = Convert.ToInt32(100 / barcodes.Count);
for (int i = 0; i < barcodes.Count; i++)
{
barcodeTextBox.SendKeys(barcodes[i]);
submitButton.Click();
Thread.Sleep(1000);
var finishButton = driver.FindElementByXPath("//a[@href='javascript:void(0);']");
finishButton.Click();
worker.ReportProgress(progressPercentage * (i + 1));
Thread.Sleep(1000);
}
}
示例8: TestUnits
public void TestUnits()
{
using (var driver = new ChromeDriver())
{
driver.Navigate().GoToUrl(ULearnUrls.StartPage);
UlearnDriver ulearnDriver = new UlearnDriver(driver);
var regPage = ulearnDriver.GoToRegistrationPage();
var random = new Random();
var login = random.Next().ToString();
var password = random.Next().ToString();
regPage.SignUp(login, password);
var startPage = ulearnDriver.GoToStartPage();
startPage.GoToCourse(Titles.BasicProgrammingTitle);
var toc = ulearnDriver.GetToc();
var unitsNames = toc.GetUnitsName();
foreach (var unitName in unitsNames)
{
if (!ulearnDriver.GetToc().GetUnitControl(unitName).Collapse)
ulearnDriver.GetToc().GetUnitControl(unitName).Click();
var slidesNames = ulearnDriver.GetToc().GetUnitControl(unitName).GetSlidesName();
foreach (var slideName in slidesNames)
{
ulearnDriver.GetToc().GetUnitControl(unitName).GetSlides().First(x => x.Name == slideName).Click();
}
}
}
}
示例9: Cannot_Register_User_With_Empty_Username
public void Cannot_Register_User_With_Empty_Username()
{
string chromeDriverDirectory = string.Format(@"{0}\..\..\..\tools", Directory.GetCurrentDirectory());
IWebDriver driver = new ChromeDriver(chromeDriverDirectory);
driver.Navigate().GoToUrl("http://localhost:64872/Account/Register");
IWebElement passwordField = driver.FindElement(By.Id("Password"));
passwordField.SendKeys("[email protected]");
IWebElement confirmPassword = driver.FindElement(By.Id("ConfirmPassword"));
confirmPassword.SendKeys("[email protected]");
IWebElement registerButton = driver.FindElement(By.ClassName("btn"));
registerButton.Click();
ReadOnlyCollection<IWebElement> errorMessages = driver.FindElements(By.XPath("//div[@class='validation-summary-errors']/ul/li"));
IWebElement errorMessage = errorMessages.FirstOrDefault();
Assert.IsNotNull(errorMessage);
Assert.AreEqual("The User name field is required.", errorMessage.Text);
driver.Quit();
}
示例10: Main
static void Main(string[] args)
{
// create an instance of webdriver
IWebDriver driver = new ChromeDriver();
// go to web page
driver.Navigate().GoToUrl("http://www.thetestroom.com/webapp");
// click on the about link
driver.FindElement(By.Id("about_link")).Click();
// check that the about page has the about zoo title
String title = driver.Title;
if (title.Equals("About Zoo"))
{
Console.WriteLine("Found the about page with the value of " + title);
}
else
{
Console.WriteLine("Instead found page with: " + title);
}
// close the driver
driver.Close();
}
示例11: CanLoadWebPageTest
public void CanLoadWebPageTest()
{
// add the directory containing chromedriver.exe to PATH
var driver = new ChromeDriver();
var baseURL = "http://localhost:6917/";
try
{
driver.Navigate().GoToUrl(baseURL + "/");
driver.FindElement(By.Id("Name")).Clear();
driver.FindElement(By.Id("Name")).SendKeys("Test");
new SelectElement(driver.FindElement(By.Id("Color"))).SelectByText("Red");
driver.FindElement(By.CssSelector("option[value=\"Red\"]")).Click();
driver.FindElement(By.CssSelector("input.btn")).Click();
var element = driver.FindElement(By.Name("PreviousNames[0].FirstName"), 3);
element.Clear();
driver.FindElement(By.Name("PreviousNames[0].FirstName")).SendKeys("ONe");
driver.FindElement(By.Name("PreviousNames[0].Surname")).Clear();
driver.FindElement(By.Name("PreviousNames[0].Surname")).SendKeys("Two");
var screenshot = driver.GetScreenshot();
screenshot.SaveAsFile("screenshot.png", ImageFormat.Png);
driver.FindElement(By.CssSelector("input.btn.btn-success")).Click();
}
catch (Exception)
{
Screenshot screenshot = driver.GetScreenshot();
screenshot.SaveAsFile("screenshot-error.png", ImageFormat.Png);
throw;
}
driver.Quit();
}
示例12: Mopayaccountcreationchrome
public void Mopayaccountcreationchrome()
{
IWebDriver driver = new ChromeDriver(@"C:\\net40\");
driver.Navigate().GoToUrl("https://devpay.mobankdev.com/Management");
new MopayAccount().Create(driver);
}
示例13: TestNewOrder_01
public void TestNewOrder_01()
{
using (var server = new ProjectSIAServer())
{
using (var chrome = new ChromeDriver())
{
chrome.Navigate().GoToUrl("http://localhost/local/add-order");
var memberName = chrome.FindElementById("input-memberName");
memberName.SendKeys("경원");
Thread.Sleep(1500);
chrome.Keyboard.SendKeys(Keys.Enter);
Thread.Sleep(500);
var productSearch = chrome.FindElementById("input-productInfo");
productSearch.Clear();
productSearch.SendKeys("머그 세");
Thread.Sleep(1000);
chrome.Keyboard.SendKeys(Keys.Enter);
Thread.Sleep(500);
chrome.Keyboard.SendKeys(Keys.ArrowUp);
Thread.Sleep(500);
productSearch.Clear();
productSearch.SendKeys("가방 꽃");
Thread.Sleep(1000);
chrome.Keyboard.SendKeys(Keys.ArrowDown);
chrome.Keyboard.SendKeys(Keys.Enter);
var buttonNewOrder = chrome.FindElementById("button-newOrder");
buttonNewOrder.Click();
Thread.Sleep(3000);
}
}
}
示例14: TestWTCDateTimePicker
public void TestWTCDateTimePicker()
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://www.wtc.nl/");
SeleniumSetMethods.EnterText(driver, "arrival1", "santiago", By.Name);
SeleniumSetMethods.EnterText(driver, "arrival1", Keys.Tab, By.Name);
SeleniumSetMethods.Click(driver, "departureDate1", "Id");
var test = driver.FindElement(By.ClassName("ui-datepicker-calendar"));
var tds = test.FindElements(By.TagName("td"));
var departureDate = tds.Where(td => td.Text == "25").FirstOrDefault();
departureDate.Click();
Thread.Sleep(1000);
SeleniumSetMethods.Click(driver, "departureDate2", "Id");
var calendar2 = driver.FindElement(By.ClassName("ui-datepicker-calendar"));
tds = calendar2.FindElements(By.TagName("td"));
var returnDate = tds.Where(td => td.Text == "30").LastOrDefault();
returnDate.Click();
Thread.Sleep(1000);
SeleniumSetMethods.Click(driver, "search_btn", "Id");
Thread.Sleep(30000);
//todo maak get methodes, om validaties te controleren
driver.Quit();
}
示例15: ChromeTest
public void ChromeTest()
{
//Store the rows that should be shown on the website
List<String> elements = new List<String>(new String[]{
"Paint Name Quantity",
"Red 3", "Turquoise 17", "Grey 5","Indigo 6"
});
//Initialize Google Chrome Browser and goes to our website
IWebDriver driver = new ChromeDriver(@"C:\Database System\Assignment1\PaintWebSite\ChromeBrowser\bin\Debug");
driver.Navigate().GoToUrl("http://localhost/PaintWebSite/PaintStore.aspx");
//Retrieve all the data in the shown table
IWebElement table = driver.FindElement(By.TagName("table"));
IList<IWebElement> tableRows = table.FindElements(By.TagName("tr"));
Assert.AreEqual(elements.Count, tableRows.Count); //Verifies whether the size of the shown table matches the expected table.
//Iterate each row of the retrieved data verifying whether the data is correct or not
foreach(IWebElement row in tableRows)
{
Assert.IsTrue(elements.Contains(row.Text), "Row " + row.Text + " incorrect");
}
//Close the browser
driver.Close();
}