本文整理汇总了C#中OpenQA.Selenium.Firefox.FirefoxDriver.Navigate方法的典型用法代码示例。如果您正苦于以下问题:C# FirefoxDriver.Navigate方法的具体用法?C# FirefoxDriver.Navigate怎么用?C# FirefoxDriver.Navigate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenQA.Selenium.Firefox.FirefoxDriver
的用法示例。
在下文中一共展示了FirefoxDriver.Navigate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
int idInicio = 30000;
int idFinal = 22000;
int contador = 1;
String url = "";
driver.Navigate().GoToUrl(url + idInicio);
driver.Manage().Window.Maximize();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"e:\AllStudents.csv", true))
{
while (idInicio > idFinal)
{
driver.Navigate().GoToUrl(url + idInicio);
IWebElement nome = driver.FindElement(By.Id("txtNome"));
IWebElement email = driver.FindElement(By.Id("txtmail_maior"));
if (email.GetAttribute("value").ToString() != "")
{
Console.WriteLine(contador + " - " + idInicio.ToString() + " - " + nome.GetAttribute("value").ToString() + " - " + email.GetAttribute("value").ToString());
file.WriteLine(contador + ";" + idInicio.ToString() + ";" + email.GetAttribute("value").ToString() +";"+ nome.GetAttribute("value").ToString());
contador++;
}
idInicio--;
}
}
}
示例2: Main
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
const int idInicio = 0;
const int idFim = 1000;
int id = idInicio;
String url = "http://fcv.matheusacademico.com.br/Aluno/frmAlunoAlteracao.asp?id=";
driver.Navigate().GoToUrl(url + id);
driver.Manage().Window.Maximize();
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\AllStudents1.txt", true))
{
while (id < idFim)
{
driver.Navigate().GoToUrl(url + id);
IWebElement nome = driver.FindElement(By.Id("txtNome"));
IWebElement email = driver.FindElement(By.Id("txtmail_maior"));
if (nome.GetAttribute("value").ToString() != "")
file.WriteLine(id.ToString() + " - " + nome.GetAttribute("value").ToString() + " - " + email.GetAttribute("value").ToString());
id++;
}
}
}
示例3: SingUp_TestUser_FindNameInHelloString
public void SingUp_TestUser_FindNameInHelloString()
{
firefox = new FirefoxDriver();
firefox.Navigate().GoToUrl("http://localhost:57336/");
firefox.FindElement(By.Id("register")).Click();
//register page
firefox.FindElement(By.Id("inputFirstName")).SendKeys("testFirstName");
firefox.FindElement(By.Id("inputLastName")).SendKeys("testLastName");
firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
firefox.FindElement(By.Id("submit")).Click();
firefox.FindElement(By.Id("login")).Click();
//log in page
firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
firefox.FindElement(By.Id("login")).Click();
firefox.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
string helloString = firefox.FindElement(By.Id("helloString")).Text;
string result = "Hello, testFirstName testLastName";
//delete test user
firefox.Navigate().GoToUrl("http://localhost:57336/User/UsersProfile");
firefox.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
firefox.FindElement(By.Id("deleteProfile")).Click();
Assert.IsTrue(result == helloString);
}
示例4: injectionAttack
public void injectionAttack()
{
FirefoxDriver ffox = new FirefoxDriver();
ffox.Navigate().GoToUrl("localhost:58374/safeinsert.aspx");
ffox.FindElementById("sname").SendKeys("Bart Simpson',4);delete from students where name='Bart Simpson';update students set gpa = 4;--");
ffox.FindElementById("sgpa").SendKeys("2.0");
ffox.FindElementById("InsertStudent").Click();
DataTable results = ServerConn.MyQuery("SELECT * FROM students");
bool InjectionFailed = false;
foreach (DataRow d in results.Rows)
{
if (d.ItemArray[1].Equals("Bart Simpson',4);delete from students where name='Bart Simpson';update students set gpa = 4;--"))
InjectionFailed = true;
}
Assert.IsTrue(InjectionFailed, "Error: Safe insert did not prevent the SQL injection");
ffox.Navigate().GoToUrl("localhost:58374/unsafeinsert.aspx");
ffox.FindElementById("sname").SendKeys("Bart Simpson',4);delete from students where name='Bart Simpson';update students set gpa = 4;--");
ffox.FindElementById("sgpa").SendKeys("4.0");
ffox.FindElementById("InsertStudent").Click();
results = ServerConn.MyQuery("SELECT * FROM students");
foreach (DataRow d in results.Rows)
{
Assert.AreEqual((float) 4, (float) d.ItemArray[2], "Error: Student {0} does not have a GPA of 4", d.ItemArray[1].ToString());
Assert.AreNotEqual("Bart Simpson", d.ItemArray[1].ToString(), "Error you didn't cover your tracks!");
}
}
示例5: XSSAttack
public void XSSAttack()
{
FirefoxDriver ffox = new FirefoxDriver();
ffox.Navigate().GoToUrl("localhost:58374/safeinsert.aspx");
ffox.FindElementById("sname").SendKeys("23',3);<script>document.body.setAttribute('style','background-image: url(\"http://vignette1.wikia.nocookie.net/simpsons/images/7/7b/Eat_My_Shorts.jpg/revision/latest?cb=20100606181712\");');</script>--");
ffox.FindElementById("sgpa").SendKeys("2.0");
ffox.FindElementById("InsertStudent").Click();
ffox.Navigate().GoToUrl("localhost:58374/unsafeshowall.aspx");
Assert.IsTrue(ffox.FindElementByTagName("body").GetAttribute("style").Contains("url(\"http://vignette1.wikia.nocookie.net/simpsons/images/7/7b/Eat_My_Shorts.jpg/revision/latest?cb=20100606181712"),"XSS Script failed to change background image");
ffox.Navigate().GoToUrl("localhost:58374/safeshowall.aspx");
Assert.IsFalse(ffox.FindElementByTagName("body").GetAttribute("style").Contains("url(\"http://vignette1.wikia.nocookie.net/simpsons/images/7/7b/Eat_My_Shorts.jpg/revision/latest?cb=20100606181712"),"SafeShowAll page failed in preventing background image from being injected");
}
示例6: Main
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://cnn.com");
while(true)
{
driver.Navigate().Refresh();
scanMainHeadline(driver.FindElement(By.ClassName("banner-text")).Text);
System.Threading.Thread.Sleep(10000);
}
}
示例7: FirefoxStartup
public void FirefoxStartup()
{
FirefoxDriver dr = new FirefoxDriver();
dr.Manage().Window.Maximize();
dr.Navigate().GoToUrl(url);
dr.Quit();
}
示例8: Main
static void Main(string[] args)
{
try
{ // Instantiating variables
string[] theURLs = new string[3];
string[] theCriteria = new string[3];
int wi, milsec=2500;
// Instantiating classes
IWebDriver wbDriver = new FirefoxDriver();
TheWebURLs webI=new TheWebURLs();
LoggingStuff logMe = new LoggingStuff();
wbDriver.Manage().Window.Maximize();
// Setting values for variables
theURLs=webI.getTheURLs();
theCriteria=webI.getSearchCiteria();
string logPath = logMe.createLogName().ToString();
/**********************************************/
// Run Test
logMe.writeFile("Selenium Test Log", false, logPath);
for(wi = 0; wi < 3; wi++)
{ // Opens the various web pages
Console.WriteLine(theURLs[wi] + ", " + theCriteria[wi]);
logMe.writeFile(theURLs[wi] + ", " + theCriteria[wi], true, logPath);
wbDriver.Navigate().GoToUrl(theURLs[wi]);
Thread.Sleep(milsec*2);
}
wbDriver.Quit();
}
catch (IOException e3)
{
Console.WriteLine("Failed during Main",e3.Message);
}
}
示例9: RunSalesExecutive
// GET: RunSystemAdministrator
public ActionResult RunSalesExecutive()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://localhost:4601/");
var emp = _employeeService
.Queryable()
.Where(x => x.DepartmentRoleId == 10)
.FirstOrDefault ();
emp.EmployeeLogin = _employeeLoginService
.Queryable()
.Where(x => x.EmployeeId == emp.EmployeeId)
.FirstOrDefault();
IWebElement UserName = driver.FindElement(By.Name("UserName"));
IWebElement Password = driver.FindElement(By.Name("Password"));
var loginButton = driver.FindElement(By.XPath("/html/body/div/div/div/section/form/button"));
UserName.SendKeys(emp.EmployeeLogin.UserName);
Password.SendKeys(emp.EmployeeLogin.Password);
loginButton.Click();
Timer timer = new Timer(1000);
timer.Start();
timer.Stop();
return View();
}
示例10: Add_Tweet_FindNewTweetInNewsfeed
public void Add_Tweet_FindNewTweetInNewsfeed()
{
firefox = new FirefoxDriver();
firefox.Navigate().GoToUrl("http://localhost:57336/");
//firefox.FindElement(By.Id("register")).Click();
firefox.FindElement(By.Id("login")).Click();
//register page
//firefox.FindElement(By.Id("inputFirstName")).SendKeys("testFirstName");
//firefox.FindElement(By.Id("inputLastName")).SendKeys("testLastName");
//firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
//firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
//firefox.FindElement(By.Id("submit")).Click();
//firefox.FindElement(By.Id("login")).Click();
//log in page
firefox.FindElement(By.Id("inputEmail")).SendKeys("[email protected]");
firefox.FindElement(By.Id("inputPassword")).SendKeys("123");
firefox.FindElement(By.Id("login")).Click();
firefox.FindElement(By.Name("Body")).Click();
firefox.FindElement(By.Name("Body")).SendKeys("test Tweet");
firefox.FindElement(By.Id("tweetbutton")).Click();
firefox.FindElement(By.Id("home")).Click();
string tweetMessage = firefox.FindElement(By.TagName("h5")).Text;
Assert.IsTrue(tweetMessage == "test Tweet");
}
示例11: Parse
public List<FootballItem> Parse() {
List<FootballItem> res = new List<FootballItem>();
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("https://www.marathonbet.com/su/popular/Football/?menu=true#");
ReadOnlyCollection<IWebElement> main = driver.FindElements(By.ClassName("sport-category-container"));
Debug.Assert(main.Count==1);
ReadOnlyCollection<IWebElement> containers = main[0].FindElements(By.ClassName("category-container"));
foreach (IWebElement container in containers) {
ReadOnlyCollection<IWebElement> tables = container.FindElements(By.ClassName("foot-market"));
Debug.Assert(tables.Count==1);
ReadOnlyCollection<IWebElement> tbodys = tables[0].FindElements(By.XPath(".//tbody[@data-event-name]"));
ParseTBody(tbodys, res);
}
/*
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until((d) => { return d.Title.ToLower().StartsWith("cheese"); });
*/
driver.Close();
driver.Quit();
return res;
}
示例12: Main
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.integrationqa.com/");
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
IWebElement menu = driver.FindElement(By.Id("hs_menu_wrapper_module_13970568219884"));
Actions builder = new Actions(driver);
builder.MoveToElement(menu).Build().Perform();
IList<IWebElement> menuItemsList = menu.FindElements(By.ClassName("hs-menu-item"));
String[] menuItems = new String[menuItemsList.Count];
int i = 0;
foreach (IWebElement menuItem in menuItemsList)
{
menuItems[i++] = menuItem.Text;
}
//Arrange all the list items in alphabetical order
IEnumerable<String> orderedMenuList = menuItems.OrderBy(lv_menu => lv_menu).ToList();
//Display the ordered list
foreach (var menuItem in orderedMenuList)
{
if (menuItem.Length > 0)
Console.WriteLine(menuItem);
}
Console.ReadKey();
}
示例13: Attack1_Protected
public void Attack1_Protected()
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://localhost/LU.ENGI3675.Project04/StudentInput.aspx");
IWebElement query = driver.FindElement(By.Name("fullName"));
query.SendKeys("a','2.1'); update students * set gpa = 4.0; --");
query = driver.FindElement(By.Name("GPA"));
query.SendKeys("3");
query = driver.FindElement(By.Name("button"));
query.Click();
System.Threading.Thread.Sleep(5000);
List<LU.ENGI3675.Proj04.App_Code.Students> students =
LU.ENGI3675.Proj04.App_Code.DatabaseAccess.Read();
bool allfour = true;
foreach (LU.ENGI3675.Proj04.App_Code.Students temp in students)
{
if (temp.GPA < 4.0) allfour = false;
Debug.Write((string)temp.Name);
Debug.Write(" ");
Debug.WriteLine((double)temp.GPA);
}
Assert.IsFalse(allfour); //if they aren't all 4.0 gpa, then protected against SQL injection
driver.Quit();
}
示例14: Test3
public void Test3()
{
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.baidu.com");
//driver.FindElement(By.LinkText("登录")).Click();
driver.FindElementById("lb").Click();
}
示例15: DriverTest
private static void DriverTest()
{
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
// Find the text input element by its name
var 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
var wait = new WebDriverWait(driver, System.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();
}