HTML element isn´t found, according to the search criteria

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Ok so I find my template throwing that same error message for the same id each time but I am not sure what to do about it.

Bulldozer mentioned increasing search criteria to make it universal. How do I do that?

I had a quick look in the manual but didn't see anything.
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
This is what I do just to make sure the element is found. Open your template in the template editor. Now go in the action recording on the web and go to the site like you were building a template. When you get to the point where the id is failing, look at all of the attributes and their values in the element properties box. You will see Href, OuterHtml, Outertext...etc. and what their values are. Take the Outerhtml and copy it into the regex builder. Change the random text to .* and the number strings to \d+ if they are in the code. Execute the regex on the string you copied over. If you get the right value in the execution result field, copy the regular expression and go to your template editor. In the element properties box, you will see a group number, attribute name and attribute value field. This should already have something in it(Id or Name) from when you recorded your template. Hit the + sign down below and give it a group number. Then in the attribute name field put OuterHtml and for the attribute value field put your regular expression that you copied. Make sure on the dropdown, you put in regex and not text. Go back to the action recording window and find the outertext attribute and value. Copy that value and do the same thing (sans regular expression builder). Hit the + button again and give it a group number. For attribute name put OuterText and attribute value the text string that was present in the element properties. Keep doing this for every attribute that you can find.

You can also make sure that what you are searching for works by using the pro branch creator in the action recording screen. Right click, pick pro branch constructor and then put in the elements (outerhtml and your regex and hit search) If it finds the element then you know it will work in the the template.
 

Stereomike

Client
Регистрация
29.03.2011
Сообщения
221
Благодарностей
30
Баллы
0
@Clint: you add several lines with that + button, what do you do about that last row 'match#' ? If I put there a number, it would only take that one item. How do I tell zenno, to take all of that kind (-1 didn't work). Eg.
I have
10 links with innertext 'more'
10 links with outerhtml 'list-more'
1 link with innertext 'more' AND outerhtml 'list-more'

Of course I want to click that last link.

How would I set that up?

Thanks!
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Since the attribute value can be a regular expression Mike you can use 'all' to get the results, but I don't think that will give you exactly what you want. Without seeing the page and testing it, there might be a couple of ways to handle it, not sure if it will work because I've never seen that situation.

You could try putting both search attributes in one group only but I do not know if that's the solution because it will pull the first match it finds.

If you send me the page url I could take a look and see if I can get it to work. Since we are dealing with a programming language that deals with searching for one attribute at a time you probably would have to do it with a regex branch from the dom text and then find the line that contains the code where both are called then use the result of that branch in your attribute value for clicking. Not sure. Maybe someone with a little more coding experience can help.
 

Здраво

Client
Регистрация
11.07.2011
Сообщения
99
Благодарностей
45
Баллы
18
I had something similar making my template broke today. I was getting error "HTML element isn´t found, according to the search criteria" but clearly all attribute names/values/search was legit. That drive me crazy. Now when I change FORM # to -1 it worked, and when was 0 or 1 it didn't worked. So I figure that -1 must be related to ultimate find, or something.

Anyone can comment on this, what doese FORM # in Html Element mean?

2011-09-28_0610.png


I must try Outerhtml regexp thx big C, helpful as usual :-).
 

Stereomike

Client
Регистрация
29.03.2011
Сообщения
221
Благодарностей
30
Баллы
0
@Clint: 'all' doesn't seem to work ('wrong input format'). I managed to do it by applying your regexp example from that first post (unique searchterm + .* for anything that messes it up with random stuff).
But I seem to not fully grasp the concept of search criteria for html elements.
See that example picture of our fellow Russian ZP user: There are 3 criterias, each should take match 0. Why? After it finds the first, the other 2 criterias will be dropped, right? Or do you build something like that, when the link could be either detected by criteria 1, 2 or 3? If 1 fails, watch for 2 then 3? Is that the concept?
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Usually, you will have match #0 if that is the only element on the page with that attribute. That won't always be the case. If you were to use the branch constructor on a page that has more than one button, or more than one form with the the the tag name input:submit, you would have to choose the right match for the form or button. Pick match #0 and you'll be filling out the wrong form.

The order of the search criteria is exactly as you explained. It will look for the first match, if fails, next and so on and so on. Let me show you a little code here to see what's happening behind the scenes.

Код:
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByName("captcha_text");
			if (he.IsVoid) {
				he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildById("captcha_text");
			}
			if (he.IsVoid) {
				he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildByAttribute("input:text", "fulltag", "input:text", "text", 4);
			}
			if (he.IsVoid) return -1;
Here it is in PM:

attributes.JPG

The code is confusing at first but if you take a closer look it will become clear. It looks for the attribute name 'Name' first with a value of "captcha_text", if it doesn't find it it searches for the attribute name 'Id' with the attribute value of "captcha_text" and if that isn't found it searches for the attribute name 'fulltag' with attribute value of "input:text" and match #4.

Since the page here only has one form with the first two attributes, the match # is 0. Since the page has more than one form with the attribute of 'input:text' it searches for the fifth form.

You can think of the groups in the element properties box like this. If you have a group with more than one search criteria, you will only get a match if all of matches are found. Think of this as 'AND'. If you have different group numbers, any of the matches will work. Think of this as 'OR'. So to find the one link Mike that you were looking for, you would have to put the attributes innertext 'more and outerhtml 'list-more' in the same group.
 
  • Спасибо
Реакции: bluescharp и Stereomike

Stereomike

Client
Регистрация
29.03.2011
Сообщения
221
Благодарностей
30
Баллы
0
Many thanks, you did a great job explaining it. Especially the group concept was fully new to me. Thanks again!
 

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