TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Asiya Durrani
NA
3
6.7k
Navigate multiple links one by one of same page using loop
Jan 9 2015 5:15 AM
How to navigate on multiple links one by one of same page by using loop in C# code for Selenium webdriver?
I want to navigate one by one on multiple links of same page By c# code using Selenium Webdriver , I used the following code but It works only one time and after back to main page not click on the second or other links:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using System.IO;
using System.Text;
using OpenQA.Selenium.Support.UI;
using System.Collections.Generic;
namespace UnitTestProject1
{
[TestClass]
public class UnitTest2
{
[TestMethod]
public void TestMethod1()
{
IWebDriver driver = new FirefoxDriver();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
// used to maximize the screen
driver.Manage().Window.Maximize();
// open website url
driver.Navigate().GoToUrl("http://testwisely.com/demo");
ICollection < IWebElement> allLinks = driver.FindElements(By.XPath("//a"));
foreach (IWebElement item in allLinks)
{
item.Click();
driver.Navigate().Back();
System.Threading.Thread.Sleep(1000);
}
}
}
}
Reply
Answers (
0
)
regarding annotations in c#
Problem with exporting data from client side in excel