FuckTheWorld / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Navigation to url hangs with chrome-driver and Chrome #1091

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Issue description:
We want to navigate to two different urls in a row with the help of the 
chrome-driver. In most cases the switch between these urls works but sometimes 
Chrome doesn't navigate to the second url.

We use the following code:
{{{
public class PlayClass {
    private static final String CHROMEDRIVER_PATH = "/home/xxx/applications/chromeServer/chromedriver";
    private static final String CHROME_DRIVER_LOG_FILE = "/tmp/chromeDriverPlay.log";

    private static DriverService driverService;

    public static void main(String[] args) throws Exception {
        WebDriver webDriver = initialiseWebDriver();
        makeTwoCallsInRow(webDriver);

        webDriver.quit();
        cleanup();
    }

    private static WebDriver initialiseWebDriver() throws IOException {
        System.setProperty("webdriver.chrome.driver", CHROMEDRIVER_PATH);

        DesiredCapabilities capability = new DesiredCapabilities();
        capability.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
        capability.setCapability("unexpectedAlertBehaviour", "accept");
        capability.setCapability("chrome.binary", CHROMEDRIVER_PATH);
        capability.setBrowserName("chrome");
        capability.setCapability("chrome.binary", CHROMEDRIVER_PATH);

        LoggingPreferences logPrefs = new LoggingPreferences();
        logPrefs.enable(LogType.BROWSER, Level.ALL);
        logPrefs.enable(LogType.CLIENT, Level.WARNING);
        logPrefs.enable(LogType.SERVER, Level.WARNING);
        logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
        capability.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--start-maximized", "--ignore-certificate-errors", "--disable-images");
        capability.setCapability(ChromeOptions.CAPABILITY, options);

        driverService = new ChromeDriverService.Builder().usingDriverExecutable(new File(CHROMEDRIVER_PATH)).usingAnyFreePort().withVerbose(true).withLogFile(new File
                (CHROME_DRIVER_LOG_FILE)).build();
        driverService.start();
        RemoteWebDriver webDriver = new RemoteWebDriver(driverService.getUrl(), capability);

        return webDriver;
    }

    private static void makeTwoCallsInRow(WebDriver webDriver) {
        webDriver.get("https://checkout.vm148.vde/?basketId=a3905f4b-336d-42e1-a72a-8bc4a18665fa&locale=DE&lang=de&shopId=783914&continueShoppingLink=http%3A%2F%2Fwww.vm148" +
                ".vde%2Ft-shirt-selbst-gestalten-C59#/spreadshirt");

        final String oldUrl = webDriver.getCurrentUrl();
        System.out.println(oldUrl);

        long startTime = System.nanoTime();
        webDriver.get("https://www.vm148.vde/login-C2108");
        long endTime = System.nanoTime();
        System.out.println(TimeUnit.NANOSECONDS.toMillis(endTime - startTime));

        WebElement element = webDriver.findElement(By.id("btnLogin"));
        System.out.println("Current element: " + element);
    }

    private static void cleanup() {
        driverService.stop();
    }
}
}}}

The call
{{{webDriver.get("https://www.vm148.vde/login-C2108");}}}
is executed but Chrome doesn't change the page and also the method returns so 
that the next call
{{{
webDriver.findElement(By.id("btnLogin"));
}}}
will fail.

To this issue we attached two log files of the chrome-driver. The first one 
(_successful.log_) contains the log when the navigation to both urls was 
successful, the other file (_navigationStopped.log_) contains the log for the 
unhappy path.

System description:
* Selenium, version 2.45.0
* Chrome, version 42.0.2311.90
* ChromeDriver, version 2.15
* Ubuntu 14.04

Original issue reported on code.google.com by n...@spreadshirt.net on 6 May 2015 at 8:02

Attachments:

GoogleCodeExporter commented 9 years ago
I cannot access the URLs provided in the code.
However, i tried with Gmail and Google URLs in your code using same 
configuration. It works fine without any issues

Can you please try to reproduce the issue with any other public URLs ?

Original comment by gmanikp...@chromium.org on 6 May 2015 at 6:46

GoogleCodeExporter commented 9 years ago
I assume that in our page there are some java-scripts running that cause the 
problem. Do you had a log into the log files?

I will try to find an example where we get also this problem.

Original comment by n...@spreadshirt.net on 7 May 2015 at 11:11

GoogleCodeExporter commented 9 years ago
So I have two urls. The first one is
https://checkout.spreadshirt.de/?basketId=2840ce86-70ab-4421-8661-c0e0a57c9978&l
ocale=DE&lang=de&shopId=205909&continueShoppingLink=http%3A%2F%2Fwww.spreadshirt
.de%2F#/spreadshirt

and the second:
https://www.spreadshirt.de/login-C2108

If you try this several times the first url will remain and the second wont 
load.

Original comment by n...@spreadshirt.net on 8 May 2015 at 7:38

GoogleCodeExporter commented 9 years ago
Thanks for the Urls.
I executed with loop of 50times, but unfortunately was not able to reproduce 
it. Every time the second URL is loaded correctly after the first one.

Does this issue happens manually (without chromedriver) as well?

Original comment by gmanikp...@chromium.org on 8 May 2015 at 7:09

GoogleCodeExporter commented 9 years ago
Mmmh. I ran the test manually without a loop, but only starting the application 
several times. After some tries it hanged. Did you run the test on a Linux 
machine? Maybe the problem is related to the Linux version of the Chromedriver 
or Chrome.

What do you mean with "manually"? 

Original comment by n...@spreadshirt.net on 11 May 2015 at 5:39

GoogleCodeExporter commented 9 years ago
There is one interesting observation. When I try it with the Firefox driver it 
works but often an error message of our webpage is shown because a service 
doesn't respond with the correct error code. When this happens a model dialog 
appears within the page. Maybe the chrome driver has a problem with the 
handling although when Chrome hangs it doesn't show this dialog.

Original comment by n...@spreadshirt.net on 11 May 2015 at 2:06

GoogleCodeExporter commented 9 years ago
I dig more deeply in this issue. There is an Ajax request that response with 0 
(in the Firefox case). According to this page 
http://stackoverflow.com/questions/3825581/does-an-http-status-code-of-0-have-an
y-meaning it means that the Ajax request was aborted. In this scenario it is 
possible because we want to switch to another page immediately. Maybe Chrome or 
the ChromeDriver don't handle this correctly and hangs in this case.

Original comment by n...@spreadshirt.net on 11 May 2015 at 2:35

GoogleCodeExporter commented 9 years ago
Can you please try to reproduce the issue with the your above given code having 
the public URLs (and not the test URLs) ? 
Please provide the verbose logs this time as well.
And how often do you see the issue ?

Original comment by gmanikp...@chromium.org on 13 May 2015 at 7:36

GoogleCodeExporter commented 9 years ago
I give you two urls from our US platform. Maybe with them you can reproduce the 
problem due to lantency or something else:

String firsturl = 
"https://checkout.spreadshirt.com/?basketId=4823fca5-7d84-4459-ab01-d3bf2b5a3f3f
&locale=US&lang=us&shopId=93439&continueShoppingLink=#/spreadshirt";

String secondurl = "https://www.spreadshirt.com/your-spreadshirt-C2108";

Meanwhile I will reproduce the problem with public urls and attach the logs.

The problem is quickly reproducible on our side. Only a few runs of the sample 
application are enough to prevent Chrome loading the next page.

Original comment by n...@spreadshirt.net on 21 May 2015 at 6:34

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Here is the debug log file from the ChromeDriver. In this session the browser 
hangs.

Original comment by n...@spreadshirt.net on 21 May 2015 at 8:11

Attachments:

GoogleCodeExporter commented 9 years ago
nils

Unable to reproduce issue with the latest chromedriver:2.16 in Ubuntu 14. 
Please try with latest chromedriver and let us know if you are still facing the 
issue

Sample Code:
private static final String CHROMEDRIVER_PATH = "/usr/local/chromedriver";
    private static final String CHROME_DRIVER_LOG_FILE = "/usr/local/chromedriver.log";

    private static DriverService driverService;
    public static void main(String[] args) throws Exception {
          WebDriver webDriver = initialiseWebDriver();
            makeTwoCallsInRow(webDriver);

            webDriver.quit();
            cleanup();
    }

     private static WebDriver initialiseWebDriver() throws IOException {
            System.setProperty("webdriver.chrome.driver", CHROMEDRIVER_PATH);

            DesiredCapabilities capability = new DesiredCapabilities();
            capability.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
            capability.setCapability("unexpectedAlertBehaviour", "accept");
            capability.setCapability("chrome.binary", CHROMEDRIVER_PATH);
            capability.setBrowserName("chrome");
            capability.setCapability("chrome.binary", CHROMEDRIVER_PATH);

            LoggingPreferences logPrefs = new LoggingPreferences();
            logPrefs.enable(LogType.BROWSER, Level.ALL);
            logPrefs.enable(LogType.CLIENT, Level.WARNING);
            logPrefs.enable(LogType.SERVER, Level.WARNING);
            logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
            capability.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

            ChromeOptions options = new ChromeOptions();
            options.addArguments("--start-maximized", "--ignore-certificate-errors", "--disable-images");
            capability.setCapability(ChromeOptions.CAPABILITY, options);

            driverService = new ChromeDriverService.Builder().usingDriverExecutable(new File(CHROMEDRIVER_PATH)).usingAnyFreePort().withVerbose(true).withLogFile(new File
                    (CHROME_DRIVER_LOG_FILE)).build();
            driverService.start();
            RemoteWebDriver webDriver = new RemoteWebDriver(driverService.getUrl(), capability);
            webDriver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
            return webDriver;
        }

        private static void makeTwoCallsInRow(WebDriver webDriver) throws InterruptedException {
            String firsturl = "https://checkout.spreadshirt.com/?basketId=4823fca5-7d84-4459-ab01-d3bf2b5a3f3f&locale=US&lang=us&shopId=93439&continueShoppingLink=#/spreadshirt";
            String secondurl = "https://www.spreadshirt.com/your-spreadshirt-C2108";

            webDriver.get(firsturl);

            final String oldUrl = webDriver.getCurrentUrl();
            System.out.println(oldUrl);

            long startTime = System.nanoTime();

            webDriver.get(secondurl);
            long endTime = System.nanoTime();
            System.out.println(TimeUnit.NANOSECONDS.toMillis(endTime - startTime));

            WebElement element = webDriver.findElement(By.id("btnLogin"));
            System.out.println("Current element: " + element);
        }

        private static void cleanup() {
            driverService.stop();
        }

Original comment by ssudunag...@chromium.org on 18 Jun 2015 at 10:27

GoogleCodeExporter commented 9 years ago
please respond to comment #12 and let us know if you are still facing issue 
with latest chromedriver.

Original comment by ssudunag...@chromium.org on 15 Jul 2015 at 8:05