Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import pyscreenshot as ImageGrab
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.support.wait import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.webdriver.common.action_chains import ActionChains
- import webbrowser
- #import urllib2
- URL = "http://vps17154.inmotionhosting.com/~heathtilevb/"
- #EMAIL = 'your email here'
- #PASSWORD = 'your password here'
- driver = webdriver.Chrome('/usr/local/chromedriver') # can be webdriver.Firefox() in your case
- driver.get(URL)
- #html_content = urllib2.urlopen('http://vps17154.inmotionhosting.com/~heathtilevb')
- wait = WebDriverWait(driver, 10)
- # login
- #form = driver.find_element_by_class_name('regular_login')
- #username = form.find_element_by_name('email')
- #username.send_keys(EMAIL)
- #password = form.find_element_by_name('password')
- #password.send_keys(PASSWORD)
- #login_button = form.find_element_by_xpath('//input[@type="submit" and @value="Login"]')
- #login_button.click()
- # search
- #search = wait.until(EC.presence_of_element_located((By.XPATH, "//form[@name='search_form']//input[@name='search_input']")))
- #search.send_keys('Kevin Rose')
- #search.send_keys(Keys.ENTER)
- # follow the link
- link = wait.until(EC.presence_of_element_located((By.LINK_TEXT, "READ MORE")))
- link.click()
- #open new tabs from matching 'view our services' - only opens single match
- body = wait.until(EC.presence_of_element_located((By.LINK_TEXT, "View Our Services")))
- #trying to find by partial link text
- #for i in range(0,999999):
- # body = driver.find_elements_by_link_text('View Our Services')
- # webbrowser.open(body)
- # body[i].click()
- #------
- #find all mathes of text
- #for i in range(0,6):
- # matches = wait.until(EC.presence_of_element_located((By.LINK_TEXT, "View Our Services")))
- # matches[i].new_tab()
- #------
- ActionChains(driver) \
- .key_down(Keys.CONTROL) \
- .click(body) \
- .key_up(Keys.CONTROL) \
- .perform()
- #body.send_keys(Keys.CONTROL)
- #body.click()
- #-- include('examples/showgrabfullscreen.py') --#
- if __name__ == "__main__":
- # fullscreen
- im=ImageGrab.grab_to_file('somefile.png')
- # im.show()
- #-#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement