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])

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-12-14
  • 2021-08-15
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
相关资源
相似解决方案