IList<IWebElement> in Arrays

370 views
Skip to first unread message

Tester Cs

unread,
May 18, 2015, 5:47:24 AM5/18/15
to seleniu...@googlegroups.com
Hi guys,

Iam new for C# and selenoum, pls help me.
This is the sample code, it working fine for me, i know its not a standard way of coding :-), but i dont knw whats the exact standard code for this.
But it will take huge time to execution, bcoz i have to extract 5000-10000 elements from each string, so is there fastest and standard code for this. Pls help me with coding, Thanks in advance, pls chk screenshot.

IList<IWebElement> ARNum = driver.FindElement(By.XPath("sumXpath1"));
IList<IWebElement> MPNum = driver.FindElement(By.XPath("sumXpath2"));
IList<IWebElement> MGNum = driver.FindElement(By.XPath("sumXpath3"));

int RowARNum=1;
foreach(IWebElement artNum in ARNum) //for First Column
{
RowARNum++;
XLWorkSheet.Cells(RowARNum, 1) = artNum.Text;
}

int RowMPNum =1;
foreach(IWebElement mpNum in MPNum) //for Second Column
{
RowMPNum++;
XLWorkSheet.Cells(RowMPNum, 1) = mpNum.Text;
}

int MGNum =1;
foreach(IWebElement mgNum in MGNum) //for Third Column
{
MGNum++;
XLWorkSheet.Cells(RowMPNum, 1) = mgNum.Text;
}
Untitled.png

Serguei Kouzmine

unread,
Jun 3, 2015, 8:35:03 PM6/3/15
to seleniu...@googlegroups.com
Hello

If you effectively perform page scraping with Selenium you may load an .GetAttribute('innerHTML') of appropriate container element, and use csquery to bulk extract
https://github.com/jamietre/CsQuery
The csquery is tolerant to poorly formatted html and may solve your perf problems

Thanks
Serguei Kouzmine
Reply all
Reply to author
Forward
0 new messages