from random import Random
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome('chromedriver')
driver.get('https://devbusiness.tunai.io/login')
time.sleep(2)
driver.maximize_window()
# Create variables for login credentials.
username = driver.find_element(By.NAME, "loginUsername");
username.send_keys("kevin@tunai");
password = driver.find_element(By.NAME, "loginPassword");
password.send_keys("123456");
login = driver.find_element(By.XPATH,"//*[@id='app']/div/div/div/div/div/div[2]/form/div[4]/button");
login.submit();
time.sleep(1)
driver.get("https://devbusiness.tunai.io/dashboard/my_salon_appointment")
time.sleep(1)
Button = driver.find_element(By.XPATH,"//*[@id='page-content']/div/div[2]/div/div/div[1]/div/div[1]/button")
Button.click()
time.sleep(1)
# trigger with other element first, add this code
element = driver.find_element(By.XPATH,"//*[@id='edit-hours']/div/div/div[2]")
driver.execute_script("arguments[0].scrollIntoView();", element)
time.sleep(1)
element.click()
# outlet button
outlet_button = driver.find_element(By.XPATH,"//*[@id='edit-hours']/div/div/div[1]")
# An kevin@tunai in the
outlet_select = driver.find_element(By.XPATH,"""//*[@id="edit-hours"]/div/div/div[3]/ul/li[2]/span""")
# Click category button to show list.
outlet_button.click()
# Click on category you want select.
outlet_select.click()
time.sleep(3)
select = Select(driver.find_element(By.XPATH,"//*[@id='edit-hours']/div[1]/select"))
select.select_by_index(3)
time.sleep(3)
driver.find_element(By.XPATH,"//*[@id='edit-hours']/div[4]/button").click()
我正在尝试执行一个网络自动化测试,现在我正纠结于如何从插座和时间列表中选择随机值。有点想不出办法了,希望有人能帮忙,提前感谢,祝你有美好的一天。
2条答案
按热度按时间6ovsh4lw1#
就我对上面代码的理解而言,应该是这样的:
jchrr9hc2#
你可以试试下面的代码: