python selinum 截取部分圖片


 file_name = "code.png"
file_path = os.path.join(pics_path, file_name)
self.driver.find_element_by_tag_name('img').screenshot(file_path)

切換窗口

driver.execute_script('window.open()')
driver.switch_to.window(self.driver.window_handles[1])
driver.get(self.url)
pics_path = self.create_file_path()
file_name = "code.png"
file_path = os.path.join(pics_path, file_name)
driver.find_element_by_tag_name('img').screenshot(file_path)
print('下載圖片成功')
driver.close()
driver.switch_to.window(self.driver.window_handles[0])

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM