Amr
Amr

Reputation: 115

How to change attribute to a random number using selenium python

    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 a random number in a specific range instead of 20, I know the randint method but I don't know how to approach it since it's a string

Upvotes: 1

Views: 112

Answers (1)

Anacktice Justice
Anacktice Justice

Reputation: 122

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)

Upvotes: 1

Related Questions