[英]How I can use result of first function in other function
我想將psw變量==>放在def test_1 / .send_keys()中
def random_list():
psw = ''
for x in range(12):
psw = psw + random.choice(list('123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'))
return psw
def test_1(driver):
driver.find_element_by_xpath("//form//a").click()
driver.find_element_by_xpath("//input[@name='tax_id']").send_keys(random_list)
您需要調用該函數。 所以driver.find_element_by_xpath(“ // input [@ name ='tax_id']”)。send_keys(random_list())– Yevhen Kuzmovych
簡單的方法:
def random_list():
psw = ''
for x in range(12):
psw = psw + random.choice(list('123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'))
return psw
def test_1(driver):
driver.find_element_by_xpath("//form//a").click()
new_random=random_list()
driver.find_element_by_xpath("//input[@name='tax_id']").send_keys(new_random)
全部一起:
def random_list():
psw = ''
for x in range(12):
psw = psw + random.choice(list('123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'))
return psw
def test_1(driver):
driver.find_element_by_xpath("//form//a").click()
driver.find_element_by_xpath("//input[@name='tax_id']").send_keys(random_list())
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.