程序完成后没有给出[xs中完成]

时间:2019-02-07 23:42:39

标签: python selenium sublimetext3

我得到了正确的结果,但是在Sublime编辑器中,完成后它总是显示[Finished in xs]

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import os
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
#chrome_options.add_argument('--start-maximized')
driver=webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://www.google.com')
print (driver.title)
x=driver.find_element_by_xpath('//*[@id="tsf"]/div[2]/div/div[1]/div/div[1]/input')
x.clear()
x.send_keys("Hello world from python")
x.send_keys(Keys.RETURN)
li=[]
links=driver.find_elements_by_xpath("//a[@href]")
li=[link.get_attribute("href") for link in links if "google" not in link.get_attribute("href")]
for i in range(2,7):
    driver.get(li[i])
    print (driver.title)
driver.close()
print ("DONE")

这是输出:

Google
Hello, World! - Learn Python - Free Interactive Python Tutorial
Python Program to Print Hello world!
Say "Hello, World!" With Python | HackerRank
Hello World: Create your First Python Program
Hello World in Python || Python Tutorial || Python Programming - YouTube
DONE

我想知道这段代码似乎有什么问题,只是它最后没有给出[Finish in ..]

0 个答案:

没有答案