我正在尝试写“10”来 值参数在这里:
<input id="import_product_categories" type="hidden" value="" name="import_params[category_ids]"></input>
使用selenium我知道它需要通过Javascript完成,并且出于某种原因,来自stackoverflow中另一个答案的以下代码不起作用
browser.execute_script("document.getElementById('import_product_categories').value+=',10'")
答案 0 :(得分:0)
java scipt代码中存在一个小错误。 js中的所有行也以;你错过了。此外,如果要将文本附加到文本框中已存在的值,请执行以下js代码
String setText = "document.getElementById('import_product_categories').value += 'hello';";
如果您不想附加文本,请执行此文本。
String setText = "document.getElementById('import_product_categories').value += 'hello';";