第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

封裝By以后,腳本只能打開登陸網(wǎng)頁(yè),登陸不進(jìn)去

封裝By以后,腳本只能打開登陸網(wǎng)頁(yè),登陸不進(jìn)去

qq_安曉東_lmpyGT 2018-05-15 19:22:12
package com.selenium.miyang.go;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.interactions.Actions;public class login { WebDriver driver; public void initDriver(){ System.setProperty("webdriver.chrome.driver", "D:\\wps\\selenium-2.42.2\\chromedriver.exe"); driver = new ChromeDriver(); driver.get("http://idcbgp.cn/user/newlogin/from_url"); driver.manage().window().maximize(); } /* *登陸腳本 *? */ public void loginScript() throws Exception{ this.initDriver(); String username = "17729597958"; String password = "andong527011764"; String userBy ="name"; String userElement = "email"; String passBy = "name"; String passElement = "password"; String buttonBy = "className"; String buttonElement = "moco-btn"; String headerBy = "id"; String headerElement = "header-avator"; String userInforBy = "className"; String userInforElement = "name"; Thread.sleep(2000); WebElement user = this.element(this.byStr(userBy, userElement)); user.isDisplayed(); WebElement userpass = this.element(this.byStr(passBy, passElement)); userpass.isDisplayed(); WebElement login_button = this.element(this.byStr(buttonBy, buttonElement)); login_button.isDisplayed(); user.sendKeys(username); userpass.sendKeys(password); login_button.click(); Thread.sleep(2000); WebElement header = this.element(this.byStr(headerBy, headerElement)); Actions action = new Actions(driver);//鼠標(biāo)懸停 action.moveToElement(header).perform(); String userInfor = this.element(this.byStr(userInforBy, userInforElement)).getText(); System.out.println(userInfor); if(userInfor.equals("慕勒2472625")){ System.out.println("登陸成功"); }else{ System.out.println("登陸失敗"); } } /*封裝By*/ public By byStr(String by,String local ){ if(by.equals("id")){ return By.id(local); }else if(equals("name")){ return By.name(local); }else if(by.equals("className")){ return By.className(local); }else{ return By.xpath(local); } } /*封裝element*/ public WebElement element(By by){ WebElement ele=driver.findElement(by); return ele; } public static void main(String[] args) throws Exception{ login action = new login(); action.loginScript(); }}
查看完整描述

目前暫無(wú)任何回答

  • 0 回答
  • 0 關(guān)注
  • 1018 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)