How can I change an attribute value in the DOM using Selenium and Python

后端 未结 2 661
名媛妹妹
名媛妹妹 2021-01-20 10:05

I\'m trying to navigate through a website using Python and Selenium and I\'ve run into an issue that I can\'t figure out how to solve (assuming it\'s even possible!)

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-20 11:04

    You can try this but understand that the site may not be OK with you sending whatever for a value. It may still limit the value to 100, etc.

    The Javascript part just takes the element you passed it and sets the value to whatever you pass in, e.g. "300".

    select = driver.find_element_by_id("uniqueid")
    WebDriver.execute_script("arguments[0].value = arguments[1]", select, "300")
    

提交回复
热议问题