from selene import browser
from my_project.helpers.data import random_number
...
for code in browser.all('.code'):
code.set_value(random_number())
One would think that it will go through all, for example 3 available fields on screen...
But in fact, if fields are dynamically loaded, the for loop may just not wait for all 3 element to appear before looping through them...
That's why, actually you need something like this:
from selene import browser
from my_project.helpers.data import random_number
...
for code in browser.all('.code').should(have.size(3)):
code.set_value(random_number())
Question, should we make it a bit more straightfoward/obvious to use?
maybe something like this (by making collection iterator waitable...):
from selene import browser
from my_project.helpers.data import random_number
...
for code in browser.all('.code')[:3]:
code.set_value(random_number())
This code may not do what the end user wants...
One would think that it will go through all, for example 3 available fields on screen... But in fact, if fields are dynamically loaded, the for loop may just not wait for all 3 element to appear before looping through them...
That's why, actually you need something like this:
Question, should we make it a bit more straightfoward/obvious to use? maybe something like this (by making collection iterator waitable...):