Hi there folks,
I was wondering if you could help me with an issue. I am developing some automation tests with the use of the .NET bindings for C# and am having trouble trying to figure out why WebDriver is slow to respond when running. Normally it runs very quickly, and does so for several tests but always slows down when it gets to that point in the test. Here is my code, and I will explain what I'm attempting to do afterwards.
bool found = false;
IWebElement edit = null;
IWebElement box = driver.FindElement(By.Id("childnode-content"));
IWebElement[] Rows = new IWebElement[30];
box.FindElements(By.TagName("tr")).CopyTo(Rows, 0);
IWebElement[] Columns = new IWebElement[10];
foreach (IWebElement i in Rows)
{
i.FindElements(By.TagName("td")).CopyTo(Columns, 0);
foreach (IWebElement a in Columns)
{
if (a == null)
{
//Do Nothing
}
try
{
a.FindElement(By.TagName("a"));
if (a.FindElement(By.TagName("a")).Text == _user)
{
found = true;
}
}
catch (Exception e)
{
//Do Nothing
}
if (found)
break;
}
if (found)
{
edit = i;
break;
}
}
if (found)
edit.FindElement(By.TagName("input")).Click();
else
throw new ElementNotVisibleException(_user + " does not exist");
Okay, so this is what I'm attempting to do. I have a webpage that I am trying to run tests on. I am using Page Objects, which represent pages within that site. Different page objects refer to separate pages, etc. The page that the code above slows down on is a simple page that has a table inside a div on the left side of the page named "childnode-content". Through this container, I am able to grab each row from the table, as well as each cell in that row. I am searching for a specific link text within one of those cells in the row in order to determine the location of that row. I then use that row and search through it for a button "input" and click on it. This would bring up a modal dialog to do some other stuff.
The issue is not that the code doesn't work, but WebDriver slows down ONLY on that page. I am able to use this same code on a different page to do the exact same thing and it runs in seconds. On the one page it does slow down, it takes upwards of 15 minutes to go through perhaps 20 rows of the table. What baffles me is that the WebDriver is only slow on this on page when it is integrated into a large NUnit test project. If I remove this code and implement it in it's own project, it runs in seconds like it should. Any ideas on what is happening, or is it just a WebDriver issue?
Also as a side note, I am contemplating changing those two WebElement arrays to a List in order to make it more dynamic. Not sure if this would speed the process up or not.