在Google Colab中使用python代码打开图像

时间:2019-08-03 12:44:41

标签: google-colaboratory

我想在python文件中编写代码并在Google collabotary中运行它,以打开Goog​​le驱动器中可用的图像,但是“显示和显示”方法不起作用。

它向我返回图像信息,而不是图像预览,如下所示:

你能帮我吗?

谢谢。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
import random

driver = webdriver.Chrome("c:\\path\\to\\chromedriver.exe")  
driver.maximize_window()
driver.get('https://www.yatra.com')

wait = WebDriverWait(driver, 10)

departure = wait.until(
    expected_conditions.presence_of_element_located((By.XPATH, "//input[@name='flight_origin_date']"))).click()

wait.until(expected_conditions.visibility_of_any_elements_located((By.XPATH,"//td[@data-date]")))
dates = driver.find_elements_by_xpath("//td[@data-date]")
driver.execute_script("arguments[0].click()",random.choice(dates))
wait.until(expected_conditions.invisibility_of_element_located((By.XPATH,"//td[@data-date]")))
destination = wait.until(
    expected_conditions.presence_of_element_located((By.XPATH, "//input[@name='flight_destination_date']"))).click()

wait.until(expected_conditions.visibility_of_any_elements_located((By.XPATH,"//td[@data-date]")))
dates = driver.find_elements_by_xpath("//td[@data-date]")
random.choice(dates).click()
wait.until(expected_conditions.invisibility_of_element_located((By.XPATH,"//td[@data-date]")))

driver.quit()

0 个答案:

没有答案