Skip to content

Instantly share code, notes, and snippets.

@pknam
Last active August 29, 2015 14:17
Show Gist options
  • Save pknam/51c6b02fdb226f2998df to your computer and use it in GitHub Desktop.
Save pknam/51c6b02fdb226f2998df to your computer and use it in GitHub Desktop.
__author__ = 'pknam'
from selenium import webdriver
import time
def main():
# browser = webdriver.PhantomJS(executable_path=r"D:\selenium_drivers\phantomjs-2.0.0-windows\bin\phantomjs.exe")
# browser = webdriver.Ie(executable_path=r"D:\selenium_drivers\Internet Explorer(x64)\IEDriverServer.exe")
browser = webdriver.Chrome(executable_path=r"D:\selenium_drivers\Chrome(x86)\chromedriver.exe")
browser.get("http://www.naver.com/")
# wait for page loading
time.sleep(1)
browser.save_screenshot('screenshot1.png')
# input search keyword
browser.find_element_by_id('query').send_keys('hahaha')
browser.find_element_by_id('search_btn').click()
# wait for page loading
time.sleep(1)
browser.save_screenshot('screenshot2.png')
browser.quit()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment