botasaurus icon indicating copy to clipboard operation
botasaurus copied to clipboard

Don't know how to clear the text area before type in

Open stevenhubhub opened this issue 1 year ago • 1 comments

When I use selenium WebDriver I know how to clear the input area because it provides a clear() method.

Hope this project can support more selenium method.

And I also feel puzzled about how to use selenium with botasaurus at the same time whit @task(becaue I am trying to get some selenium WebDriver method to handle some element, like clear the input area).

stevenhubhub avatar Jun 17 '24 21:06 stevenhubhub

I try to use JS script to clear but find the driver.run_js() only can pass an argument. because if it is selenium driver, I can pass two arguments to the driver.excute_script(). because every element id is different. If I use tdriver.run_js() to clear target element text area I need repeat type same code every time.

js_clear = """/**

  • @param {string} id */ var target_id = arguments[0]; function clearInputValue(target_id) { var input = document.getElementById(target_id); input.value = ''; } """

if it is selenium driver, I can let my code like this: driver.excute_script(js_clear, target_id)

but driver.run_js() can't.

stevenhubhub avatar Jun 18 '24 21:06 stevenhubhub

use el.run_js

Chetan11-dev avatar Apr 11 '25 09:04 Chetan11-dev