Code Creator and set value of File input control

solution84

Client
Регистрация
11.06.2013
Сообщения
7
Благодарностей
1
Баллы
0
Hello,

I need to set value of file input control on page, I try SetValue, SetAttribute... but still don't know :(

Here is a code sample:

Код:
// Event click [tag=input:file]
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("uploaded_file");
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByAttribute("input:file", "fulltag", "input:file", "text", 0);
}
if (he.IsVoid) return -1;

// WHAT CODE GOES HERE TO SET VALUE ON FILE FOR EXAMPLE: c:\\1.txt
// I TRY THIS BUT DON'T KNOW WHAT NEXT
he.RiseEvent("click", instance.EmulationLevel);  // - this open Dialog and I don't know how to set file path to this dialog 
//he.SetValue("c:\\1.txt","Full",false);			
//he.SetAttribute("value","c:\\1.txt");
//Emulator.SendText(instance.ActiveTab.Handle,"c:\\1.txt"); // I try this to send text on open dialog but now work
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
834
Баллы
113
Emulator is not necessary here. It should work with he.SetValue("c:\\1.txt","Full",false);, without rise click before. If it doesn't work as well let me know the site in PM
 

solution84

Client
Регистрация
11.06.2013
Сообщения
7
Благодарностей
1
Баллы
0
Emulator is not necessary here. It should work with he.SetValue("c:\\1.txt","Full",false);, without rise click before. If it doesn't work as well let me know the site in PM
I try this but NOT WORK, THIS CODE JUST OPEN DIALOG NOT SET FILE PATH :( :( :(

I created site just for testing this: http://file.zaljubise.net/

Here is a full code:

instance.ClearCookie();

Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("http://file.zaljubise.net/", "");
if (tab.IsBusy) tab.WaitDownloading();


// Event click [tag=input:file]
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildById("MainContent_FileUpload1");
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByName("ctl00$MainContent$FileUpload1");
}
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByAttribute("input:file", "fulltag", "input:file", "text", 0);
}
if (he.IsVoid) return -1;

he.SetValue("c:\\1.txt","Full",false);
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
834
Баллы
113
call instance.SetFilesForUpload(); before
 

solution84

Client
Регистрация
11.06.2013
Сообщения
7
Благодарностей
1
Баллы
0
call instance.SetFilesForUpload(); before
I change the code but still NOT WORK :(

Here is the code:

Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("http://file.zaljubise.net/", "");
if (tab.IsBusy) tab.WaitDownloading();

// Event click [tag=input:file]
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildById("MainContent_FileUpload1");
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByName("ctl00$MainContent$FileUpload1");
}
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByAttribute("input:file", "fulltag", "input:file", "text", 0);
}
if (he.IsVoid) return -1;

instance.SetFilesForUpload("C:\\1\\1.txt");
he.RiseEvent("click", instance.EmulationLevel); // I try this OR
he.SetValue("C:\\1\\1.txt","Full",false);// this still NOT WORK :(
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
I change the code but still NOT WORK :(

Here is the code:

Tab tab = instance.ActiveTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("http://file.zaljubise.net/", "");
if (tab.IsBusy) tab.WaitDownloading();

// Event click [tag=input:file]
HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildById("MainContent_FileUpload1");
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByName("ctl00$MainContent$FileUpload1");
}
if (he.IsVoid) {
he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByAttribute("input:file", "fulltag", "input:file", "text", 0);
}
if (he.IsVoid) return -1;

instance.SetFilesForUpload("C:\\1\\1.txt");
he.RiseEvent("click", instance.EmulationLevel); // I try this OR
he.SetValue("C:\\1\\1.txt","Full",false);// this still NOT WORK :(
It's work only in ZennoPoster. In debug mode (PM or CC) it's not work. it was always so.
 

solution84

Client
Регистрация
11.06.2013
Сообщения
7
Благодарностей
1
Баллы
0

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63

Вложения

Hungry Bulldozer

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

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