#coding:GBK
'''
Created on 2017年8月4日

@author: peiwenxiang
'''

import time
import re
import os
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC


def email():
  while True:
    te = driver.find_element_by_xpath('//*[@]/table/tbody/tr[2]/td/div[1]/div[1]/div/a[1]/span').click()#删除
    time.sleep(2)
    

    #判断alert提示是否存在
    result = EC.alert_is_present()(driver)
    if result:
      alert = driver.switch_to_alert()
      alert.accept()
      time.sleep(2)

 


options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["ignore-certificate-errors"])
driver = webdriver.Chrome(chrome_options=options)
driver.get('http://mail.vcredit.com/login.jsp')
driver.maximize_window()
driver.implicitly_wait(60)

time.sleep(2)

uname = driver.find_element_by_name('username')
uname.send_keys('*****@vcredit.com')

pword = driver.find_element_by_name('passwd')
pword.send_keys('******')

time.sleep(1)

driver.find_element_by_name('B1').click()

time.sleep(1)

#删除收件箱
driver.find_element_by_xpath('//*[@]/li[1]/a').click()

time.sleep(1)

email()

#删除已删除里面的邮件

driver.find_element_by_xpath('//*[@]/li[4]/a').click()
time.sleep(1)

email()

driver.quit()

#结束相关进程

ifexistchrome=os.system('tasklist|findstr "chrome.exe"')
ifexistDr=os.system('tasklist|findstr "chromedriver.exe"')
if ifexistchrome==0 and ifexistDr==0:
  os.system('taskkill /f /im "chrome.exe"')
  os.system('taskkill /f /im "chromedriver.exe"')
ifexistcmd=os.system('tasklist|findstr "chrome.exe"')
if ifexistcmd==0:
  os.system('taskkill /f /im "cmd.exe"')

相关文章:

  • 2022-12-23
  • 2021-10-21
  • 2021-04-06
  • 2021-12-25
  • 2021-12-24
  • 2022-01-13
  • 2022-12-23
猜你喜欢
  • 2021-10-30
  • 2022-01-17
  • 2022-01-20
  • 2022-12-23
  • 2021-05-19
  • 2021-10-31
  • 2022-03-11
相关资源
相似解决方案