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
driver = webdriver.Chrome('ChromeDriver')
driver.get("https://devbusiness.tunai.io/login")
time.sleep(2)
driver.maximize_window()
#log in 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(3)
driver.get("https://devbusiness.tunai.io/dashboard/salon_report_voucher")
time.sleep(3)
driver.find_element(By.XPATH, '//*[@id="packageTable"]/tbody[1]/tr/td[1]').click()
time.sleep(2)
driver.find_element(By.XPATH,'//*[@id="packageTable"]/tbody[1]/tr').click()
time.sleep(2)
#trigger the element before click
voucher = driver.find_element(By.XPATH, "//*[@id='packageTable']/tbody[2]/tr[1]")
driver.execute_script("arguments[0].click();", voucher)
time.sleep(2)
driver.find_element(By.XPATH, '//*[@id="packageTable"]/tbody[2]/tr[1]')
time.sleep(2)
#trigger the detail button
detail = driver.find_element(By.XPATH, "//*[@id='checkAll']")
driver.execute_script("arguments[0].click();", detail)
time.sleep(5)
driver.find_element(By.XPATH, "//*[@id='checkAll']")
time.sleep(5)
driver.find_element(By.XPATH, '//*[@id="voucherModal___BV_modal_body_"]/div/div/button[1]').click()
time.sleep(5)
我想点击编辑新价格并输入一个新价格,保存并循环它。现在,我不允许输入新价格并继续。我复制了Xpath并尝试,但失败了,所以我认为是因为弹出页面。这就是失败的原因。
1条答案
按热度按时间dgjrabp21#
要单击
Edit Price
按钮,请使用webdriverwait()并等待元素可单击并跟随xpath
。然后等待模型弹出,然后输入值。
你需要导入下面的库.