Is there a solution if the SetAttribute of GetElementById does not work?

Asked 2 years ago, Updated 2 years ago, 56 views

https://www.paypal.com/myaccount/transfer/buy

I just type characters in the ID element text box.

webBrowser1.Document.GetElementById("recipient").SetAttribute("value", "test@mail");

With the above code, you can enter it on the surface, but the characters are not reflected in the value.
(Also, the text box disappears when you click it.)

Note: Problem symptom has been GIFed.
Enter a description of the image here

1st time, input to textbox, click button after disable attribute 入力 Back to before input

Enter //textbox
  dynamic document = webBrowser1.Document.DomDocument;
  document.getElementById("recipient").value="test@mail";
  // disable attribute disabled
  dynamic document = webBrowser1.Document.DomDocument;
  document.querySelector("input[type=submit]") .disabled=false;

The second time, as you asked, you can confirm that the textbox disappears by typing the above code into the textbox and clicking on the textbox.(I think it's not reflected in the value.)

Third time, if you try the above code contents manually, you can see that it will move to the next screen.

If you know the cause, please let me know.
I look forward to your kind cooperation.
visual studio express 2015 for desktop (64bit) windows 10

javascript c# html

2022-09-30 19:35

2 Answers

The value property of the HTMLInputElement can vary with user input, so the initial value of the value attribute is the Specification not to synchronize.


2022-09-30 19:35

Attributes include the content and IDL attributes, some of which do not match the properties.The value attribute is also different from the value property.
Then, as for the solution, How do I handle disabled in the webbrowser automation process? but HTML operations are simple.

dynamic document=webBrowser1.Document.DomDocument;
document.getElementById("recipient").value="test@mail";

will do.

Clicking on the text box also erases the characters entered

I understand that the input itself seems to have been successful.In addition, isn't it possible that automatic operation measures have been implemented on the website and the input contents have been reset? This is due to a specific site, and if automated operations are avoided, it could also be unauthorized access.


2022-09-30 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.