'Put value in divs per digit(6-digit code) with Python Selenium

I put value in 6-digit code but i cant continue. I do this:

    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/div[1]/div[1]')
    driver.execute_script("arguments[0].setAttribute('data-value',arguments[1])",d, list_vcode[0])
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/input')
    driver.execute_script("arguments[0].setAttribute('value',arguments[1])", d, list_vcode[0])
    time.sleep(20)
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/div[1]/div[3]')
    driver.execute_script("arguments[0].setAttribute('data-value',arguments[1])", d, list_vcode[1])
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/div[1]/div[5]')
    driver.execute_script("arguments[0].setAttribute('data-value',arguments[1])", d, list_vcode[2])
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/div[2]/div[1]')
    driver.execute_script("arguments[0].setAttribute('data-value',arguments[1])", d, list_vcode[4])
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/div[2]/div[3]')

    driver.execute_script("arguments[0].setAttribute('data-value',arguments[1])", d, list_vcode[5])
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/div/div[2]/div[5]')
    driver.execute_script("arguments[0].setAttribute('data-value',arguments[1])", d, list_vcode[6])
    d = driver.find_element_by_xpath('//*[@id="root"]/div/div/div/div/div/div[2]/div[1]/div/div/div/div/div/div/div/div[2]/div/div[2]/div/input')

This work for put the value but no for continue to the next step.

Im doing this to auto-connect my wallet in OpenSea(Fortmatic)

You can see it in OpenSea, press show more options and choose formatic, enter ramdom email and see the html of 6 digit code: [https://opensea.io/login?referrer=%2Faccount%2Fsettings][1]

The only solution I could think of was for the program to simulate keystrokes. If someone knows how to do it in that situation. I have tried with the Selenium Keys package and press when find the html body but not work. [1]: https://opensea.io/login?referrer=%2Faccount%2Fsettings



Solution 1:[1]

I was able to automate as below.

@FindBy(xpath="//iframe[@class='fortmatic-iframe']") WebElement fortmaticIframe;

@FindBy(xpath="//input[@inputmode='numeric']") WebElement verificationCodeAllTextfield;

switchToFortmaticIframe(); verificationCodeAllTextfield.sendKeys(code);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sach