How to count no. of elements?

  • Автор темы Автор темы bytzu
  • Дата начала Дата начала

bytzu

Client
Регистрация
26.07.2013
Сообщения
15
Реакции
2
Баллы
3
Hello,


I scrape different pages each with different no of elements (div's with class='test' ) with the help of action designer. How can i know how many elements we have on each page?

Then i want to set a index and add each element to a list, but how can i know how many elements i have on each page ?

I give you an ex. in PHP maybe is more clear:

$index = 0;

//step 1

if($index < count($nr_of_elelments)){
//do something
$index++;
//go back to step 1
}else{
//do something else
}

I am interested on getting count($nr_of_elelments)

Anyone knows how to do this?
 
Hello,


I scrape different pages each with different no of elements (div's with class='test' ) with the help of action designer. How can i know how many elements we have on each page?

Then i want to set a index and add each element to a list, but how can i know how many elements i have on each page ?

I give you an ex. in PHP maybe is more clear:

$index = 0;

//step 1

if($index < count($nr_of_elelments)){
//do something
$index++;
//go back to step 1
}else{
//do something else
}

I am interested on getting count($nr_of_elelments)

Anyone knows how to do this?
use C#:
JavaScript:
Развернуть Свернуть Копировать
var col = instance.ActiveTab.FindElementsByAttribute("div", "class", "test", "text");
return col.Count;
 
  • Спасибо
Реакции: bytzu
Thanks shade for your solution. It works fine. Looks like i will need to take a C# crash course

Out of curiosity does anybody knows another solution around it? There is another way getting the DOM and with regular expression putting the values into a list and then count list elements, but Shade's solution is the best until now.
 
  • Спасибо
Реакции: LightWood
His solutions are always the best. He's the man!
 
  • Спасибо
Реакции: shade

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)