- Регистрация
- 16.03.2013
- Сообщения
- 231
- Благодарностей
- 36
- Баллы
- 28
Hi guys, trying to develop a fb template and i'm having this issue with click some elements. The innerText is always the same but the class is random, so depends on how it generates the page, sometimes it clicks sometimes it doesn't. I have found this snippet on the forum but i can't find a way to make it click. If there is anybody out there who can help me, i'm even willing to pay for the trouble. It's eating my brains and days.
So basically it only needs to click on a field with the name "Category" and "Location"
If anybody has a better other, or better said any other option please let me know, i hope i will make it worth your while.
This is the best thing i've found so far, but when i put it in c# it throws off the whole template, giving some c# errors.
So basically it only needs to click on a field with the name "Category" and "Location"
If anybody has a better other, or better said any other option please let me know, i hope i will make it worth your while.
This is the best thing i've found so far, but when i put it in c# it throws off the whole template, giving some c# errors.
C#:
var tab = instance.ActiveTab;
var rnd = new Random ();
HtmlElement el = tab . FindElementByAttribute ( " tag " , " attribute name " , " value " , " regexp " , 0 ); // looking for element
int elX = el.DisplacementInTabWindow.X; // находим "leftinbrowser"
int elY = el.DisplacementInTabWindow.Y; // находим "topinbrowser"
int elWidth = el . Width ; // element width
int elHeight = el . Height ; // element height
int elCrdX = rnd . Next ( elX , elX + elWidth ); // calculate the X coordinates randomly within the element
int elCrdY = rnd . Next ( elY , elY + elHeight ); // randomly calculate y coordinates within the element
tab . touch . Touch ( elCrdX , elCrdY ); // perform a touch on the coordinate.
// if you need the area to be much smaller than the element itself,
// in this case, in rnd.Next(elX, elX + elWidth) add to leftinbrowser - elX the desired number of pixels
// for example rnd.Next(elX + 50, elX + elWidth - 50) which will add 50px on the X axis on the left and subtract 50px on the right
// same with the y-axis, but don't overdo it too much, because if minValue is greater than maxValue it will throw an error