hello all, again here. I need some help ๐ฆ
From the DOM, I have this div element with 6 input elements having the class. I want to use Playwright and Python to access each of these elements and place a specific value in each input of the div.
<div class="OTPForm_otpForm__uLxqO"><input class="OTPForm_input__n25Kb " placeholder="-" type="number" value="2"><input class="OTPForm_input__n25Kb " placeholder="-" type="number" value=""><input class="OTPForm_input__n25Kb " placeholder="-" type="number" value=""><input class="OTPForm_input__n25Kb " placeholder="-" type="number" value=""><input class="OTPForm_input__n25Kb " placeholder="-" type="number" value=""><input class="OTPForm_input__n25Kb " placeholder="-" type="number" value=""></div>I already provided this code, and I want to be able to iterate over each element to place the corresponding value in each one. However, it's not working as expected, as I see the cursor moving over each element, but it doesn't place the value "1" in the input with class at position 0, "2" in the input with class at position 1, and so on. I want to correct this so that it works as intended.
Here is a snippet of my function's code: # Get the div and input elements # div_element = page.query_selector(".OTPForm_otpForm__uLxqO") input_elements = page.query_selector_all(".OTPForm_otpForm__uLxqO input.OTPForm_input__n25Kb")
# Values I want to fill in the input fields
valores_a_completar = ["1", "2", "3", "4", "5", "6"]
# Fill each element with the corresponding value
for input_element, valor in zip(input_elements, valores_a_completar):
# Simulate input event before filling the value
input_element.dispatch_event("input")
input_element.fill(valor)
thanks in advance
This thread is trying to answer question "How can I use Playwright and Python to access each input element in a div from the DOM and place a specific value in each input?"
This is a video of problem that I face https://github.com/Bancar/uala-accounts-qa/assets/87529848/cae6b277-022c-4821-b5d4-0fe0cb02d852
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].