在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ 如何模擬選定指定的文件并刪除(python+selenium)?

如何模擬選定指定的文件并刪除(python+selenium)?

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
target = "https://pan.baidu.com/"
driver.get(target)
driver.find_element_by_xpath('//div[@class="account-title"]/a').click()
driver.find_element_by_xpath('//input[@id="TANGRAM__PSP_4__userName"]').send_keys('name')
driver.find_element_by_xpath('//input[@id="TANGRAM__PSP_4__password"]').send_keys('passwd')
driver.find_element_by_xpath('//input[@id="TANGRAM__PSP_4__submit"]').click()
path = driver.find_element_by_xpath('//a[@title="test"]')
ActionChains(driver).move_to_element(path).perform() 
ActionChains(driver).context_click(path).perform()

 

上面的代碼執(zhí)行后,呈現(xiàn)下面的狀態(tài)

圖片描述

繼續(xù)往下走,
driver.find_element_by_xpath('//*[@class="context-menu"]/ul/li[21]').click()

勝利在望了,

圖片描述

如何模擬那個(gè)確定?
driver.find_element_by_xpath('/html/body/div[10]/div[3]/a[1]').click()
不可以

回答
編輯回答
裸橙

定位確定按鈕:

button_ok = driver.find_element_by_css_selector('#confirm a.g-button-blue-large')
2018年5月12日 09:24
編輯回答
近義詞
    s = driver.find_element_by_css_selector('#i02937128695981601') # 刪除按鈕的id
    ActionChains(driver).click(s).perform() # 點(diǎn)擊刪除
    p = driver.find_element_by_xpath('//*[@id="confirm"]/div[3]/a[1]/span')
    ActionChains(driver).click(p).perform() # 點(diǎn)擊確定
2018年4月15日 19:05