I can check the check box with Javascript, but input type="checkbox" does not have checked.

Asked 2 months ago, Updated 2 months ago, 3 views

I'm scraping my company site with Python and selenium, but after checking the check box, there is a button to press [Confirm button].

So, after accessing the site with selenium, I thought about checking the check box in the script below.

script='document.querySelector('CSS selector in check box").checked=true;'
driver.execute_script(script)

However, there is a temporary check, but when I checked the HTML, the input type="checkbox" is not followed by checked.

If you don't add Checked, the check will disappear if you scroll back to the screen.
Therefore, when I press [confirm button], nothing responded...

Of course, .click() has a check, and input type="checkbox" followed by checked, but I don't want to use .click() because the HTML changes and the css selector deviates.

I apologize for the inconvenience, but I appreciate your cooperation.

python html google-chrome selenium

2022-09-30 11:09

1 Answers

Briefly, I think the form itself works as a function, so the most important thing to check is whether Java actually selects the ID and checks it, looks elsewhere, or blinds it.


2022-09-30 11:10

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.