Getting the attribute using -1 for document Number in c#

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
12
Баллы
18
1.This ProjectMaker action:

should be translated to this:

Код:
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("-1").FindElementByAttribute("div", "class", "awesomeClass", "text", 0);
string leftPlusButt = he.GetAttribute("height");
BUT while using -1 for the Document# in the ProjectMaker action will correctly get the attribute, when using the same value in the C# code it will not get any value at all.

if I'm using:

Код:
[CODE]HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("div", "class", "awesomeClass", "text", 0);
string leftPlusButt = he.GetAttribute("height");
I will get the expected value but this means I cannot use -1 when I'm unsure of the exact document #. Can someone tell me why this behavior?

2. Where is the Form# in the C# code?
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 413
Благодарностей
5 900
Баллы
113
Form can be specified using FindElementByTag method, here is the example:
Код:
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 1).FindChildById("text");
But if you want to search elements in all documents (-1) and all forms (-1) on webpage, just use FindElementByAttribute method without GetDocumentByAddress and FindElementByTag.
 
  • Спасибо
Реакции: zenfreak

zenfreak

Client
Регистрация
21.08.2013
Сообщения
249
Благодарностей
12
Баллы
18
Now it makes sense, thank you!

For those who didn't understand, my initial code should be:

Код:
HtmlElement he = instance.GetTabByAddress("page").FindElementByAttribute("div", "class", "awesomeClass", "text", 0);
string leftPlusButt = he.GetAttribute("height");
 

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