Whats best way to handle this?

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
I am regging a 2.0 site and they have added a long series of next buttons. There is no pageload since it's a window
so unless I put in an extra long delay it can overrun them and error, especially if I run many threads.

A wait for element would solve this easily, but that's not available yet right?

There are like 6 or these in a series, am I going to have to set up 6 loops
to keep checking for text presence or am I missing a better way?

ZP is great but browser based so already kinda slow, with all of these extra delays it's slower still =(

Anyone have a better way to do this?
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
oops dupe post
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
I do something like wait for element
JavaScript:
HtmlElement he;
for(int i=0;i<20;i++)
{
	he = instance.ActiveTab.FindElementByAttribute("Your data in parameters");
	if(!he.IsVoid)
	{
		break;
	}
	System.Threading.Thread.Sleep(2000);
}
Very good, I am not quite sure of what I need to put in "your data in parameters"
could you expand on that a bit, maybe give an example?

Thanks for help.
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
("a", "href", "http://zennolab.com", "text", 0)

Whatever is in the action designer for the element you are looking for. "a" would be in the Tag field..."href" in the Attribute name field..."http://zennolab.com" is the Attribute value...."text" is search type and 0 would be whatever match# you have.
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
("a", "href", "http://zennolab.com", "text", 0)

Whatever is in the action designer for the element you are looking for. "a" would be in the Tag field..."href" in the Attribute name field..."http://zennolab.com" is the Attribute value...."text" is search type and 0 would be whatever match# you have.
Got it.
Thanks!
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
Meh Code is giving me an error :(

Compile code of actionaction group id: 3be0fc92-ed76-4470-96b6-33ba21b3105a Error in action "CS1501" "No overload for method 'FindElementByAttribute' takes 4 arguments". [Строка: 4; Cтолбец: 10]
zp-error-1.png



Not sure if I have made a mistake in entering data or if it is something else.
I tried adding values without the "" also in case using them is wrong, same result.


I don't know enough about C# to know what could be wrong. I Googled for answers as well but it's like reading Chinese.
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
Provide your code part here
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
he = instance.ActiveTab.FindElementByAttribute("a","fulltag","a","text",28);
if(!he.IsVoid)
{
break;
}
System.Threading.Thread.Sleep(2000);
 
  • Спасибо
Реакции: mark leenheer

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
Wow, can not believe I missed that.... derp.
Works great thanks.
 

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
Actually it works OK, but I've noticed it's taking a long time to find the elements 35+ seconds.

http://screencast.com/t/GHwZr4I3D8BW

Is this correct way to use it, put C# in front/on top of element I am waiting for?

Any reason why it could be taking so long to find the element? Visually it is there after just a second or two.

Код:
HtmlElement he;
for(int i=0;i<20;i++)
{
    he = instance.ActiveTab.FindElementByAttribute("a","class","regexp","tumblelog_compact_control follow chrome blue",0);
    if(!he.IsVoid)
    {
        break;
    }
    System.Threading.Thread.Sleep(2000);
}
I've tried using several different elements, they are all taking about 35 seconds to identify.
Any clue what could be going on? Are they somehow able to block or slow this action?

Anything I can try to overcome it?
 

Stroks

Client
Регистрация
09.02.2012
Сообщения
219
Благодарностей
14
Баллы
18
Why don't you try to click on the element, and if click isn't successful you wait for 5 seconds and repeat this step (click again)? You do this till the element click is successful.

This is what I do on a flash based site to check if an article was successfully added over there.

This method doesn't include coding and it probably works on each site where the coding version works.
 
  • Спасибо
Реакции: mark leenheer

mark leenheer

Client
Регистрация
29.01.2012
Сообщения
156
Благодарностей
6
Баллы
0
Why don't you try to click on the element, and if click isn't successful you wait for 5 seconds and repeat this step (click again)? You do this till the element click is successful.

This is what I do on a flash based site to check if an article was successfully added over there.

This method doesn't include coding and it probably works on each site where the coding version works.
Yes I know I can do that, but the entire point of this thread was to find a cleaner easier way to do that without all the loops
and delays.

The C# code is supposed to do that, but it's not.

Thanks for the suggestion though, it looks like I will have to resort to that.

I am still very curious what they are doing to stop that C# code from working as it should?
 

Stroks

Client
Регистрация
09.02.2012
Сообщения
219
Благодарностей
14
Баллы
18
I didn't read the first post thoughtfully.

Having said that, one way or another you have to wait some time and then check the page's code. The method above is clean, because you check if element is there and then wait if it isn't. So you just add a wait on the bad end of the element. It couldn't be cleaner than that. With code you have System.Threading.Thread.Sleep(2000); and this is a wait too.

Having said this I am not sure which method is faster, if the speed is what you are looking for.
 

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