3 Replies - 222 Views - Last Post: 20 July 2012 - 01:56 PM Rate Topic: -----

#1 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

change webbrowser.document.getfilebyid("xxx"), then change DOM

Posted 20 July 2012 - 01:07 PM

So I've wasted about 20 hours now on this, and to warn everyone I'm still learning.

I have logged into a website in a webbrower I opened in c# winform and navigated to a certain section of website. Now I am at a fileupload screen. The area where the path is to be typed in is locked on website, you have to hit browse to point to file to populate text box.

I am stuck on trying to populate FileUpLoad1 text area. My code so far is below:
Just to experiment, I manually hit browse and inserted a file. Then I used the watch list, filtered down to the item I am looking for which is FileUpLoad1. Then one of the DOMELEMENTS.IHTMLInputElement_value is equal to the file I manually inserted.
So I'm guessing if I change this .DOMELEMENTS.IHTMLInputElement_value, that would insert the name I WANT. then I can just hit UPLOAD MAIN BUTTON.

The code below filters to the item I want but I've tried many different ways to change this value and nothing is working. Any idea what I am doing wrong??

thanks!!

            foreach (HtmlElement link in webBrowser3.document.GetElementsByTagName("INPUT"))
            {
                if (link.Id == "FileUpLoad1")
                {
                    //1st try
                    var t3 = link.GetAttribute("value");
                    link.SetAttribute("value", "hi");
                    var t4 = link.GetAttribute("value");
                    //2nd try
                   var doc = webBrowser3.Document;
                    var txtBox1 = doc.All["FileUpLoad1"];
                    txtBox1.SetAttribute("value", "hello");
                    var t1 = txtBox1.GetAttribute("value");
                }
                
            }


Is This A Good Question/Topic? 0
  • +

Replies To: change webbrowser.document.getfilebyid("xxx"), then change DOM

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,924
  • Joined: 02-June 10

Re: change webbrowser.document.getfilebyid("xxx"), then change DOM

Posted 20 July 2012 - 01:39 PM

So you're saying you're trying to make a 'bot that uploads and the website was programmed against that sort of thing but you want to bypass that anyway. Is that about right? I'd even further guess this is for one of those "Make 200 identity profiles" contract jobs on vWorker or oDesk. Am I close?

I think you're making a lot of assumptions about the site. You are assuming that the browse button just gets a local file path and dumps it into the text area. I'd bet it does a lot more than that: Like double checking the file type, image dimensions are within limits and so on. You're assuming the text area can be set directly when in fact it may be binded to a property that has to be set in code behind the page after validation is done. Etc. Etc.
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3621
  • View blog
  • Posts: 11,280
  • Joined: 05-May 12

Re: change webbrowser.document.getfilebyid("xxx"), then change DOM

Posted 20 July 2012 - 01:51 PM

Ostensibly in this thread, he claims that he is trying to upload a file for online trading.

The technology/techniques that I'm helping him out with does have "non-civilian uses", like that bot you mentioned. Should I desist?
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5578
  • View blog
  • Posts: 11,924
  • Joined: 02-June 10

Re: change webbrowser.document.getfilebyid("xxx"), then change DOM

Posted 20 July 2012 - 01:56 PM

It could very well be for the purpose mentioned.

However, if there is already a thread open for this same topic we do not want duplicate threads opened. This thread should be merged with that one - or just closed since the other thread is already getting response.

Solarissf: Please don't open duplicate threads for the same thing. This one is being closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1