def signIn(self):
        if self.params['driver'] == 'chrome':
            self.driver = webdriver.chrome()
        elif self.params['driver'] == 'firefox':
            self.driver = webdriver.Firefox()
        elif self.params['driver'] == 'edge':
            self.driver = webdriver.edge()
        elif self.params['driver'] == 'ie':
            self.driver = webdriver.ie()
        elif self.params['driver'] == 'opera':
            self.driver = webdriver.opera()
        elif self.params['driver'] == 'safari':
            self.driver = webdriver.safari()
        else:
            return False  #driver undefined
        self.initDriver = True
        self.driver.get('https://www.linkedin.com/login')

        # signin
        user_field = self.driver.find_element_by_xpath(
            "//input[@id='username']")
        user_field.send_keys(self.params['email'])
        pass_field = self.driver.find_element_by_xpath(
            "//input[@id='password']")
        pass_field.send_keys(self.params['password'])
        self.driver.find_element_by_xpath(
            "//button[@data-litms-control-urn='login-submit']").click()
        return True
Esempio n. 2
0
def setUp(browser):
    if browser == 'chrome':
        driver = webdriver.Chrome(executable_path="C:\\Users\\Admin\\Desktop\\test\\chromedriver.exe")
    elif browser =='firefox':
        driver = webdriver.Firefox(executable_path="C:\\Users\\Admin\\Desktop\\test\\geckodriver.exe")
    else:
        driver = webdriver.safari()
    return driver
 def __init__(self, browser, base_url):
     if browser == "firefox":
         self.wd = webdriver.Firefox()
     elif browser == "chrome":
         self.wd = webdriver.Chrome()
     elif browser == "safari":
         self.wd == webdriver.safari()
     else:
         raise ValueError ("Unrecognized browser %s" % browser)
     self.wd.implicitly_wait(1)
     self.session = SessionHelper(self)
     self.group = GroupHelper(self)
     self.address = AddressHelper(self)
     self.base_url = base_url
Esempio n. 4
0
from selenium import webdriver
import time

driver = webdriver.safari()
driver.get("https://opensource-demo.orangehrmlive.com/index.php/auth/login")

driver.find_element_by_id("txtUsername").clear()
driver.find_element_by_id("txtUsername").send_keys("Admin")
driver.find_element_by_id("txtPassword").clear()
driver.find_element_by_id("txtPassword").send_keys("admin123")
driver.find_element_by_id("btnLogin").click()
driver.find_element_by_xpath(
    "(.//*[normalize-space(text()) and normalize-space(.)='Register OAuth Client'])[1]/following::b[1]"
).click()
time.sleep(3)
driver.close()
Esempio n. 5
0
# Currently works for Safari, but just change to whichever 
# browser you're using.

import time
#Changed the method of opening the browser.
#Selenium allows for the page to be refreshed.
from selenium import webdriver

#adding ability to change number of repeats
count = int(input("1: "))
#Same as before
x = input("Insert Video Here): ")
print( "Insert Time Here:")
minutes = int(input("Minutes "))
seconds  = int(input("Seconds "))

#Calculating the refreshrate from the user input
refreshrate = minutes * 60 + seconds
#Selecting Safari as the browser
driver = webdriver.safari()
driver.get("http://"+x)

for i in range(count):
    #Sets the page to refresh at the refreshrate.
    time.sleep(refreshrate)
    driver.refresh()
from selenium import webdriver

driver = webdriver.safari()     # 打开 Chrome 浏览器

# 将刚刚复制的帖在这
driver.get("https://morvanzhou.github.io/")
driver.find_element_by_xpath(u"//img[@alt='强化学习 (Reinforcement Learning)']").click()
driver.find_element_by_link_text("About").click()
driver.find_element_by_link_text(u"赞助").click()
driver.find_element_by_link_text(u"教程 ▾").click()
driver.find_element_by_link_text(u"数据处理 ▾").click()
driver.find_element_by_link_text(u"网页爬虫").click()

# 得到网页 html, 还能截图
html = driver.page_source       # get html
driver.get_screenshot_as_file("./img/sreenshot1.png")
driver.close()