Vishal Dusane

Vishal Dusane

  • 1.2k
  • 465
  • 50.1k

how navigate Page to new link using Selenium webdriver C#.

Sep 20 2016 5:38 AM

  1. Now i want to redirect the my current page to check new form of family details form so how can i do this
  2. HTML code for family details link is
    1. <a href="/Admin/CountryMaintenanace"><span>Maintenance</span></a> 



  3. using System.IO;  
  4. using System.Text;  
  5. using OpenQA.Selenium;  
  6. using OpenQA.Selenium.Chrome;  
  7. using OpenQA.Selenium.Support.UI;  
  8. using System.Drawing.Imaging;  
  9.   
  10. namespace eulogin  
  11. {  
  12.     class Program  
  13.     {  
  14.         static void Main(string[] args)  
  15.         {  
  16.             // Initialize the Chrome Driver  
  17.             using (var driver = new ChromeDriver(@"C:\Users\v.dusane\Documents\Visual Studio 2012\Projects\ToolsQA"))  
  18.             {  
  19.                 // Go to the home page  
  20.                 driver.Navigate().GoToUrl("http://localhost:36000/login");  
  21.   
  22.                 // Get the page elements              
  23.                 driver.FindElement(By.Id("UserName exampleInputEmail2")).SendKeys("Admin");  
  24.                 driver.FindElement(By.Id("Pwd exampleInputPassword2")).SendKeys("Admin@123");  
  25.                 driver.FindElement(By.Id("logid")).Click();  
  26.                 driver.FindElement(By.LinkText("/Admin/CountryMaintenanace")).Click();     
  27.   
  28.                 // Take a screenshot and save it into screen.png  
  29.                 driver.GetScreenshot().SaveAsFile(@"screen.png", ImageFormat.Png);  
  30.             }  
  31.         }  
  32.     }  


Answers (2)