web-dev-qa-db-ja.com

java.net.ConnectException:IEDriverServerおよびIE 11 on Windows 10)を使用したSelenium3.11.0でローカルホストエラーに接続できませんでした

私はSeleniumを初めて使用し、ラップトップでSeleniumをセットアップしようとしています。単純なコードからIEを呼び出すことができません。詳細を以下に示します。問題がどこにあるのかを理解するのを手伝ってください。

IEバージョン:IE 11、IEドライバー:64ビット、OS:Windows 10 64ビット、Seleniumバージョン:3.11

エラー:

Started InternetExplorerDriver server (64-bit)
3.9.0.0
Listening on port 29313
Only local connections are allowed
Exception in thread "main" org.openqa.Selenium.WebDriverException: Java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:08.638Z'
System info: Host: 'DESKTOP-B1D1PSJ', ip: '192.168.79.96', os.name: 'Windows 10', os.Arch: 'AMD64', os.version: '10.0', Java.version: '1.8.0_161'
Driver info: driver.version: InternetExplorerDriver
        at org.openqa.Selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.Java:92)
        at org.openqa.Selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.Java:545)
        at org.openqa.Selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.Java:209)
        at org.openqa.Selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.Java:223)
        at org.openqa.Selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.Java:215)
        at org.openqa.Selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.Java:152)
        at testing.Tryselenium.main(Tryselenium.Java:31)
Caused by: Java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:29313
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.Java:240)
        at okhttp3.internal.connection.RealConnection.connect(RealConnection.Java:158)
        at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.Java:256)
        at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.Java:134)
        at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.Java:113)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.Java:42)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.Java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.Java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.Java:125)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.Java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.Java:200)
        at okhttp3.RealCall.execute(RealCall.Java:77)
        at org.openqa.Selenium.remote.internal.OkHttpClient.execute(OkHttpClient.Java:101)
        at org.openqa.Selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.Java:101)
        at org.openqa.Selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.Java:73)
        at org.openqa.Selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.Java:136)
        at org.openqa.Selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.Java:83)
        ... 6 more
Caused by: Java.net.ConnectException: Connection refused: connect
        at Java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
        at Java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
        at Java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
        at Java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
        at Java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at Java.net.PlainSocketImpl.connect(Unknown Source)
        at Java.net.SocksSocketImpl.connect(Unknown Source)
        at Java.net.Socket.connect(Unknown Source)
        at okhttp3.internal.platform.Platform.connectSocket(Platform.Java:125)
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.Java:238)

コード:

mport Java.util.Arrays;
import Java.util.List;
import Java.util.concurrent.TimeUnit;

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.chrome.ChromeOptions;
import org.openqa.Selenium.firefox.FirefoxDriver;
import org.openqa.Selenium.ie.InternetExplorerDriver;
import org.openqa.Selenium.remote.DesiredCapabilities;

public class Tryselenium {
          public static void main(String[] args) { 
            // TODO Auto-generated method stub

                  WebDriver web;
                  /*System.setProperty("webdriver.chrome.driver","C:\\Users\\Divakar\\Documents\\General\\Learnings\\Selenium\\Others\\Set Up files\\Browser Drivers\\" + "chromedriver_x32.exe");
                  ChromeOptions chromeOptions = new ChromeOptions();
                        chromeOptions.setExperimentalOption("excludeSwitches",Arrays.asList("test-type"));
                        web = new ChromeDriver(chromeOptions);
                        web.manage().window().maximize();
                        web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);*/
                        
                  System.setProperty("webdriver.ie.driver","E:\\General\\Learnings\\Selenium\\Others\\Set Up files\\Browser Drivers\\" + "IEDriverServer.exe");
                        DesiredCapabilities capab = DesiredCapabilities.internetExplorer();
                capab.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
                web = new InternetExplorerDriver();
                web.manage().window().maximize();
                web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);

                    /*FirefoxDriver web = new FirefoxDriver();                  
                web = new FirefoxDriver();      
                web.manage().window().maximize();
                web.manage().timeouts().implicitlyWait(50,TimeUnit.SECONDS);*/
                
                web.get("http://www.icicibank.com/");
                web.findElement(By.xpath("/html/body/div[1]/div[1]/div[1]/div/a[1]")).click();
                web.findElement(By.xpath("/html/body/div[1]/div[1]/div[1]/div/div[3]/div/ul[1]/li[1]/a")).click();
            web.findElement(By.xpath("/html/body/div[1]/div[2]/div[2]/div/div[1]/div/div[3]/a")).click();
            web.findElement(By.name("AuthenticationFG.USER_PRINCIPAL")).sendKeys("507133118");
            web.findElement(By.name("AuthenticationFG.ACCESS_CODE")).sendKeys("Soft2008");
            web.findElement(By.name("Action.VALIDATE_CREDENTIALS")).click();
            web.findElement(By.id("ContentLink1")).click();
            

            WebElement accttable =  web.findElement(By.xpath("/html/body/form/div/div[3]/div[1]/div[4]/div[2]/div/div/div[5]/div/div/div/div/div/div/div"));
                List<WebElement> all_rows =  accttable.findElements(By.tagName("tr"));
            
                int j = 0;
                for (int i = 0; i < all_rows.size(); i++) {
                List<WebElement> rowAllCells = all_rows.get(i).findElements(By.tagName("td"));                    
                        if(rowAllCells.size()>1)
                        {

                                String acctno=rowAllCells.get(2).getText();
                                if(rowAllCells.get(2).getText().trim().equalsIgnoreCase("602605049934"))
                                {
                                        web.findElement(By.id("AccountSummaryFG.SELECTED_INDEX")).click(); ///html/body/form/div/div[3]/div[1]/div[4]/div[2]/div/div/div[5]/div/div/div/div/div/div/div/table/tbody/tr[4]/td[1]/input
                                        web.findElement(By.id("HREF_actNicNameOutput[" + j + "]")).click();
                                        web.findElement(By.id("backBtn")).click();
                                        web.findElement(By.id("VIEW_MINI_STATEMENT")).click();
                                        web.findElement(By.id("HREF_Logout")).click();
                                        web.close();
                                }
                                else                            j = j + 1;
                        }
                }
            
                        
            
          }
        }
3

私たちの場合の問題は、Jenkinsに固有ではなく、Chromeドライバーのクラッシュ自動化テストが実行されるVMの下。

VMマシンにログインし、ワークスペースがコピーされた場所にログインし、ターミナルでJenkinsと同じmavenコマンドを実行すると、テストの実行を監視できるはずです。問題を特定して修正する方法になります。

enter image description here

enter image description here

enter image description here

0

この回答は、Edgeブラウザー用に更新されています。 Edge Browserを使用していて、同じ問題に直面している場合。次に、次の手順に従います。

  1. この場所から最新のIEDriverServerをダウンロードします: https://Selenium.dev/downloads/

  2. 次のようにコードを更新します。

import org.openqa.Selenium.By;
import org.openqa.Selenium.WebDriver;
import org.openqa.Selenium.Edge.EdgeDriver;

public class SL001_OpenWebpage_Edge 
    {
        public static void main(String[] args) 
        {       
            System.setProperty("webdriver.ie.driver", "\\location\\IEDriverServer.exe");

            WebDriver driver=new EdgeDriver();

            driver.get("https://www.hul.co.in/");

            driver.findElement(By.id("tcm:1255-50553-4")).click();

            //driver.manage().window().maximize();

        }
    }
0