Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

This my code:

mins = WebDriverWait(browser, 30).until(EC.visibility_of_element_located((By.NAME, "yt_min")))

browser.execute_script("arguments[0].setAttribute('value', '20');", mins)

I want it to change it to the random number in the specified range instead of 20, I know the randint method but I don't know how to approach it since it's the string

1 Answer

0 votes
by (36.8k points)

You can use the below code:

import random

A = random.randint(range here)

mins = WebDriverWait(browser,  30).until(EC.visibility_of_element_located((By.NAME, "yt_min")))

browser.execute_script("arguments[0].setAttribute('value', f'{str(A)}');", mins)

 Do check out data science with python certification to understand from scratch

Related questions

Browse Categories

...