1

私はselenium2(selenium-java:3.0.1)とphantomjs-2.1.1-linux-x86_64を使用しています。私がしようとしているのは、SSOが必要なページにアクセスすることです。ブラウザを使用してWebサイトにアクセスすると、ユーザ名とパスワードを入力するためのログインダイアログがポップアップ表示されます。selenium2 + phantomjs webdriverを使用してSSOを渡すには?

wgetを使用してURLを取得する場合。それは認証部分で停止しました。

[email protected]:wget https://www.example.com/details 
--2016-11-15 05:18:02-- https://www.example.com/details 
Resolving www.example.com (www.example.com)... 10.20.30.40 
Connecting to www.example.com (www.example.com)|10.20.30.40|:443... connected. 
HTTP request sent, awaiting response... 302 Found 
Location: /detaisl [following] 
--2016-11-15 05:18:02-- https://www.example.com/login 
Reusing existing connection to www.example.com:443. 
HTTP request sent, awaiting response... 302 Found 
Location: https://sso.example.com/idp/SSO.saml2?SAMLRequest=...something not related... [following] 
--2016-11-15 05:18:02-- https://sso.example.com/idp/SSO.saml2?SAMLRequest=...something not related... 
Resolving sso.example.com (sso.example.com)... 11.22.33.44 
Connecting to sso.example.com (sso.example.com)|11.22.33.44|:443... connected. 
HTTP request sent, awaiting response... 302 Found 
Location: https://sso.example.com/idp/95wM4/resumeSAML20/idp/SSO.ping [following] 
--2016-11-15 05:18:02-- https://sso.example.com/idp/95wM4/resumeSAML20/idp/SSO.ping 
Reusing existing connection to sso.example.com:443. 
HTTP request sent, awaiting response... 401 Unauthorized 

Username/Password Authentication Failed. 

selenium2(セレンのJava:3.0.1)を使用して、次のコード

WebDriver webdriver = new PhantomJSDriver(); 
webdriver.get("https://www.example.com/details"); 
System.out.println(webdriver.getCurrentUrl()); 
System.out.println(webdriver.getTitle()); 
System.out.println(webdriver.getPageSource()); 

出力とphantomjs-2.1.1-Linuxをx86_64である:

Nov 15, 2016 5:36:07 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init> 
INFO: executable: ./phantomjs-2.1.1-linux-x86_64/bin/phantomjs 
Nov 15, 2016 5:36:07 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init> 
INFO: port: 27571 
Nov 15, 2016 5:36:07 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init> 
INFO: arguments: [--webdriver=27571, --webdriver-logfile=./phantomjsdriver.log] 
Nov 15, 2016 5:36:07 AM org.openqa.selenium.phantomjs.PhantomJSDriverService <init> 
INFO: environment: {} 
[INFO - 2016-11-15T13:36:07.904Z] GhostDriver - Main - running on port 27571 
[INFO - 2016-11-15T13:36:08.113Z] Session [76cd8ec0-ab38-11e6-bceb-256426a0974e] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true} 
[INFO - 2016-11-15T13:36:08.113Z] Session [76cd8ec0-ab38-11e6-bceb-256426a0974e] - page.customHeaders: - {} 
[INFO - 2016-11-15T13:36:08.113Z] Session [76cd8ec0-ab38-11e6-bceb-256426a0974e] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}} 
[INFO - 2016-11-15T13:36:08.115Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 76cd8ec0-ab38-11e6-bceb-256426a0974e 
about:blank 

<html><head></head><body></body></html> 

それはまるで空白のページだけを開くようなものだ。ユーザー名とパスワードをポップアップダイアログに入力してアクセスを続ける方法はありますか?

答えて

0

この種のエラーを処理するためにこのコードを使用してください。SSLハンドシェイクエラーがほとんどの場合、この種のエラーを処理するために次のコードを使用することをお勧めします。

DesiredCapabilities caps = new DesiredCapabilities(); 
      caps.setJavascriptEnabled(true);     
      caps.setCapability("takesScreenshot", true); 
      caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,**Path**//phantomjs.exe");         

//あなたがWebDriverWaitを使用している場合

caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[]{"--ignore-ssl-errors=true"}); 

//はログ

caps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[]{"--webdriver-loglevel=NONE"}); 

    driver = new PhantomJSDriver(caps); 

を無効にするには、SSLエラーの処理については、私はあなたがPhantomJSからのログを無効にすることをお勧めします。

関連する問題