0

ログイン用のこれらのテキストフィールドに入力し、ログインボタンを押す必要があります (ある種の自動ログイン)。

Web ページへのリンクは次のとおりです。Telekom Email Login Page

これは私が使用している3つの方法です。

public String exportDriver() throws IOException {
        final InputStream IEDriverStream = getClass().getResourceAsStream("/Driver/IEDriverServer.exe");
        final File ieDriverServer = FileWebOpener.stream2file(IEDriverStream, "IEDriverServer", ".exe");
        System.setProperty("webdriver.ie.driver", ieDriverServer.getAbsolutePath());
        return ieDriverServer.getAbsolutePath();
    }

    public void goToWebsite(String url) {
        driver = new InternetExplorerDriver();
        driver.get(url);
    }

    public void setUsernameAndPassword(String username, String password, int Website) throws InterruptedException {
       try{ new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#user[name='pw_usr']"))).sendKeys(username);
        driver.findElement(By.cssSelector("input#pw_pwd[name='pw_pwd']")).sendKeys(password);
        driver.findElement(By.cssSelector("input.button.standard_button_size.large#pw_submit")).click();
    } catch(Exception e){
           e.printStackTrace();
       }
    }

これは私が得る例外です

4

5 に答える 5

0

アプリケーションが遅すぎると思われます。WebDriverWait要素を識別してからSendkeys操作するために使用します。

package pkg1;

import java.io.File;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class testIE {

    public static void main(String[] args) {

        System.setProperty("webdriver.ie.driver", System.getProperty("user.dir") + File.separator + "\\Executables\\IEDriverServer.exe");
        WebDriver driver = new InternetExplorerDriver();        
        driver.get("https://accounts.login.idm.telekom.com/idmip?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.return_to=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Fverify%3FreturnToUrl%3Dhttps%3A%2F%2Femail.t-online.de%2Fem&openid.realm=https%3A%2F%2Ftipi.api.t-online.de&openid.assoc_handle=S4d53c348-b3f2-49a9-b13e-65ade0af6da4&openid.mode=checkid_setup&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_request&openid.ext1.type.attr1=urn%3Atelekom.com%3Aall&openid.ext1.required=attr1&openid.ns.ext2=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Foauth2%2F1.0&openid.ext2.client_id=10LIVESAM30000004901PORTAL00000000000000&openid.ext2.scopes=W3sic2NvcGUiOiJzcGljYSJ9XQ%3D%3D&openid.ns.ext3=http%3A%2F%2Fidm.telekom.com%2Fopenid%2Fext%2F2.0&openid.ext3.logout_endpoint=https%3A%2F%2Ftipi.api.t-online.de%2Fsrp-auth%2FoneIdm%2Flogout&openid.ns.ext4=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fui%2F1.0&openid.ext4.mode=popup");
        WebDriverWait wait = new WebDriverWait(driver, 30);
        WebElement user= wait.until(ExpectedConditions.elementToBeClickable(By.id("user")));
        user.sendKeys("user12345@gmail.com");
        WebDriverWait wait1 = new WebDriverWait(driver, 30);
        WebElement pass= wait1.until(ExpectedConditions.elementToBeClickable(By.id("pw_pwd")));
        pass.sendKeys("password");


    }

}

出力 ここに画像の説明を入力

于 2019-03-31T13:52:25.247 に答える