Mr.HB i need ur help?

webmuthu

Пользователь
Регистрация
27.11.2012
Сообщения
43
Благодарностей
0
Баллы
6
Mr. HB, thanks a lot for your valuable guidance. I did some work with your tricks. U the guy exactly understands my queries.

Here, let me tell u login "click" issue in login page.

Normally the page has login button only. Its submitting button and I set this for form value -1. I load random url from a list, varying in language. Some pages has search button also.
Both buttons having same attributes except their ID.

Look at these properties.

name="op"
id='edit-name1"
form=0

name="op"
id='edit-name2"
form=1

name="op"
id='edit-name3"
form=2

Id property is varying in login page depending upon the availability of search. If search button is available on the page, search event get raised. If not it works fine.

Simply says I can't predict the form number and ID of the login button. How can I fix this?

U really understands this, hoping so.
And one more, is there any C# code available for fixing escape string. (system&112; &113;&114;-)

Thanks in advance
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
I do that with c# and first I find login field then I'm able to get form number of this filed. Login button will have the same form number as login field. So that's how I do that.
You can do that w/o code. Start formNumber from 0 and try to find login field if there is error - > increase form nmber+1. Finally you get it.
 

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
:az:
 

webmuthu

Пользователь
Регистрация
27.11.2012
Сообщения
43
Благодарностей
0
Баллы
6
yae........ i got it.

i've found some c# code from this discussion forum. And i modified for my query. this is the code. it works fine.

// get variables from project
string vURL = project.Variables["URL"].Value;
string vValue = project.Variables["sub_id"].Value;

// init
Tab tab = instance.ActiveTab;
Document doc = tab.MainDocument;

// setup form
HtmlElement myForm = doc.CreateElement("form");
myForm.SetAttribute("id", "user-login");
myForm.SetAttribute("method", "post");
myForm.SetAttribute("action", vURL);

HtmlElement hiddenField1 = doc.CreateElement("input");
hiddenField1.SetAttribute("type", "hidden");
hiddenField1.SetAttribute("name", "form_id");
hiddenField1.SetAttribute("value", "user_login");

HtmlElement myButton = doc.CreateElement("input");
myButton.SetAttribute("type", "submit");
myButton.SetAttribute("id", vValue);

// manipulate dom
doc.Body.AppendChild(myForm);
doc.FindElementById("myPostForm").AppendChild(hiddenField1);
doc.FindElementById(vValue).AppendChild(myButton);

// click submit button
doc.FindElementById(vValue).Click();
 

webmuthu

Пользователь
Регистрация
27.11.2012
Сообщения
43
Благодарностей
0
Баллы
6
yae........ i got it.

i've found some c# code from this discussion forum. And i modified for my query. this is the code. it works fine.

// get variables from project
string vURL = project.Variables["URL"].Value;
string vValue = project.Variables["sub_id"].Value;

// init
Tab tab = instance.ActiveTab;
Document doc = tab.MainDocument;

// setup form
HtmlElement myForm = doc.CreateElement("form");
myForm.SetAttribute("id", "user-login");
myForm.SetAttribute("method", "post");
myForm.SetAttribute("action", vURL);

HtmlElement hiddenField1 = doc.CreateElement("input");
hiddenField1.SetAttribute("type", "hidden");
hiddenField1.SetAttribute("name", "form_id");
hiddenField1.SetAttribute("value", "user_login");

HtmlElement myButton = doc.CreateElement("input");
myButton.SetAttribute("type", "submit");
myButton.SetAttribute("id", vValue);

// manipulate dom
doc.Body.AppendChild(myForm);
doc.FindElementById("myPostForm").AppendChild(hiddenField1);
doc.FindElementById(vValue).AppendChild(myButton);

// click submit button
doc.FindElementById(vValue).Click();
 

gemini

Client
Регистрация
10.03.2011
Сообщения
160
Благодарностей
31
Баллы
28
I do that with c# and first I find login field then I'm able to get form number of this filed. Login button will have the same form number as login field. So that's how I do that.
You can do that w/o code. Start formNumber from 0 and try to find login field if there is error - > increase form nmber+1. Finally you get it.
How do you do that? I can't find a way to get number of the form.
html element has method ParentForm but how to get number of this form in document?
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
JavaScript:
var tab = instance.ActiveTab;
if(tab.IsBusy) tab.WaitDownloading();
var he = tab.FindElementByAttribute("textarea","name","text","text",0);
var parentForm = he.ParentForm;
he = parentForm.FindChildByAttribute();
 
  • Спасибо
Реакции: gemini

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 770
Благодарностей
1 182
Баллы
113
JavaScript:
var tab = instance.ActiveTab;
if(tab.IsBusy) tab.WaitDownloading();
var he = tab.FindElementByAttribute("textarea","name","text","text",0);
var parentForm = he.ParentForm;
he = parentForm.FindChildByAttribute();
Ошибка в действии "CS1501" "No overload for method 'FindChildByAttribute' takes 0 arguments" в строке "he = parentForm.FindChildByAttribute();
"
 

Hungry Bulldozer

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

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