Ejemplo n.º 1
0
class main():
    dr = webdriver.Firefox()
    dr.maximize_window()
    sleep(5)
    url = "https://www.imooc.com/user/newlogin"

    dr.get(url)

    sleep(3)
    dr.find_element(By.XPATH('//*[@id="sigin"]/div[1]/h1/span[1]'))
    sleep(3)
    dr.find_element(By.NAME("email")).click()
    sleep(3)
    dr.find_element(By.NAME("email")).send_keys("*****@*****.**")
    dr.find_element(By.NAME("password")).send_keys("f12547414")
    dr.find_element(By.value("登录")).click()
Ejemplo n.º 2
0
 def getLocator(self, locator):
     by = None
     key = locator.split(":")
     if len(key) == 1:
         by = By.ID(locator)
     elif len(key) == 2:
         key[0] = key[0].lower()
         key[1] = key[1].strip()
     if key[0] == "id":
         by = By.ID(key[1])
     if key[0] == "name":
         by = By.NAME(key[1])
     if key[0] == "xpath":
         by = By.XPATH(key[1])
     if key[0] == "linktext":
         by = By.LINK_TEXT(key[1])
     elif key[0] == "particallinktext":
         by = By.PARTIAL_LINK_TEXT(key[1])
     else:
         print("NO LOCATOR MATCHED")
     return by
Ejemplo n.º 3
0
 def choose(self, drop_down_select: tuple, name: str):
     drop_down = WebDriverWait(self, 100).until(
         EC.visibility_of_element_located(drop_down_select))
     drop_down.find_element(By.NAME(name)).click()
Ejemplo n.º 4
0
from selenium import webdriver

import time

from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
base_url = 'https://www.126.com/'
driver.get(base_url)
time.sleep(5)
# driver.switch_to_frame('//*[@id="x-URS-iframe1552355264449.2908"]')
# driver.find_element_by_name('email').send_keys('sss')
# driver.find_element_by_name('password').send_keys('sadad')

driver.find_element(By.NAME('email'))
# driver.find_element_by_xpath('//*[@id="auto-id-1552357575647"]')
# driver.find_element_by_id('login_button').click()
time.sleep(5)
driver.quit()