這裏是我需要輸入新密碼並重復它,然後點擊'創建'的窗口。 Python的webdriver從主窗口切換到彈出窗口(不是Java警報)和登錄
我迄今爲止代碼:
createLogin = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="Item.MessageUniqueBody"]/div/div/div/div/div[2]/div[2]/a')))
createLogin.click()
time.sleep(10)
try:
newPassword = self.driver.find_elements_by_xpath('//*[@id="editNewUser_newPassword"]')
newPassword1 = self.driver.find_elements_by_xpath('//*[@id="editNewUser_newPasswordRepeat"]')
newPasswordForm = self.driver.find_elements_by_xpath('//*[@id="editNewUserPasswordForm"]/table/tbody/tr[1]/td[1]')
self.driver.switch_to.active_element(newPasswordForm)
time.sleep(3)
newPassword.send_keys('123')
newPassword1.send_keys('123')
time.sleep(2)
# createLog = wait.until(
# EC.presence_of_element_located((By.XPATH, '//*[@id="editNewUserPassword_save"]')))
# createLog.click()
# time.sleep(5)
except NoAlertPresentException as e:
time.sleep(2)
myAccount = wait.until(
EC.presence_of_element_located((By.XPATH, '//*[@id="easMyAccount1"]')))
myAccount.click()
time.sleep(5)
什麼是問題嗎? –
問題是 - 我得到一個錯誤:self.driver.switch_to.active_element(newPasswordForm) TypeError:'dict'對象不可調用 – user2771350
active_element不是一種方法,它是一個包含有關活動元素信息的字典 –