Beispiel #1
0
def getElements():
    # for more info, see https://www.selenium.dev/documentation/en/webdriver/web_element/
    try:
        # *** OLD WAY ***
        # elem = browser.find_element_by_class_name('card-img-top')
        # linkElem = browser.find_element_by_id('minecraft')
        # linkElem = browser.find_element_by_link_text("See what's new in the second edition.")

        # *** NEW WAY ***
        linkElem = browser.find_element(
            By.linkText("See what's new in the second edition."))

        print('Found <%s> element.' % type(linkElem))

        return linkElem
    except:
        print("Was not able to find that element.")
Beispiel #2
0
 def test_login(self):
     self.driver.get('https://www.baidu.com/')
     # self.driver.find_element(By.CSS_SELECTOR, '[class="index_head_info_pCDownloadBtn"]').click()
     self.driver.find_element(By.ID, 'kw').send_keys('python')
     time.sleep(3)
     self.driver.find_element(By.linkText("百度一下")).click()
Beispiel #3
0
driver.find_element_by_xpath('//*[@id="app"]/div/footer/a[1]/div[2]').click()
time.sleep(2)
driver.find_element_by_xpath('//*[@id="app"]/div/footer/a[2]/div[1]/div').click()
time.sleep(2)
driver.find_element_by_xpath('//*[@id="app"]/div/footer/a[3]/div[1]/div').click()
time.sleep(2)
driver.find_element_by_xpath('//*[@id="app"]/div/footer/a[4]/div[1]/div').click()
time.sleep(2)

driver.find_element(By.CLASS_NAME("input.fy-flex-2")).clear();
driver.findElement(By.cssSelector("input.fy-flex-2")).sendKeys("13333333338");
driver.findElement(By.xpath("//input[@type='password']")).clear();
driver.findElement(By.xpath("//input[@type='password']")).sendKeys("111111");
driver.findElement(By.xpath("//div[@id='app']/div/div[2]/button")).click();
driver.findElement(By.cssSelector("div.header-content")).click();
driver.findElement(By.linkText("退出登录")).click();
driver.findElement(By.cssSelector("input.fy-flex-2")).clear();
driver.findElement(By.cssSelector("input.fy-flex-2")).sendKeys("13333333338");
driver.findElement(By.xpath("//input[@type='password']")).clear();
driver.findElement(By.xpath("//input[@type='password']")).sendKeys("111111");
driver.findElement(By.xpath("//div[@id='app']/div/div[2]/button")).click();
driver.findElement(By.cssSelector("div.link")).click();
driver.findElement(By.cssSelector("div.mine-icon.icon-img")).click();
driver.findElement(By.cssSelector("img.img")).click();
driver.findElement(By.linkText("退出登录")).click();
driver.findElement(By.cssSelector("input.fy-flex-2")).clear();
driver.findElement(By.cssSelector("input.fy-flex-2")).sendKeys("13333333338");
driver.findElement(By.xpath("//input[@type='password']")).clear();
driver.findElement(By.xpath("//input[@type='password']")).sendKeys("111111");
driver.findElement(By.xpath("//div[@id='app']/div/div[2]/button")).click();
driver.findElement(By.linkText("我的")).click();