setattribute

How to change the date of a hidden element of a Datepicker using setAttribute method and Selenium with Python?

杀马特。学长 韩版系。学妹 提交于 2021-02-02 09:25:28
问题 I have been struggling for days to find a way to set a date of a datepicker using Selenium with Python. I found out that there is a hidden element with the date, so I tried javascript executor to set a value to that hidden element. I tried different ways, and the scripts seem to execute fine, but the date doesn't change. My script looks like this: #input date by using hidden date method 1 element = browser.find_element_by_xpath("/html[1]/body[1]/div[1]/form[1]/table[1]/tbody[1]/tr[1]/td[1]

Change value attribute by class via JavaScript

女生的网名这么多〃 提交于 2020-05-10 09:28:47
问题 I have the following HTML: <input class="vertical-tabs-active-tab" type="hidden" value="account" name="tabs__active_tab"> I need JavaScript that will change the value of "account" to "yolo". I thought I could do this: document.getElementsByClassName('vertical-tabs-active-tab').setAttribute("value", "yolo"); But that produces an error of: document.getElementsByClassName(...).setAttribute is not a function I'm not able to add an "id" to input, I have to change the value based on class. 回答1: