selenium icon indicating copy to clipboard operation
selenium copied to clipboard

ChromeDriver.getCurrentUrl() results in infinite loop for XML pages.

Open ghost opened this issue 8 years ago • 7 comments

Meta

OS: Windows, Linux

Selenium Version: 2.52.0

Browser: Chrome

Browser Version: 64.0.3282.140 (32-bit)

Expected Behavior

When calling webDriver.getCurrentUrl() whilst being on an XML page, it should return the address of that XML page.

Actual Behavior

Instead of returning the URL, it infinitely loops and times out.

Steps to reproduce

The code at our company is a lot more than that, but I tried to boil it down to the actual issue (which is the 'getCurrentUrl' call).

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

WebDriver webDriver = new ChromeDriver();
webDriver.navigate().to("https://github.com/SeleniumHQ/selenium/blob/ceaf3da79542024becdda5953059dfbb96fb3a90/.idea/androidDexCompiler.xml");
webDriver.getCurrentUrl();

ghost avatar Feb 12 '18 10:02 ghost

@NicolasKogler Can you try with below code .

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class CurrentURLTest {
	public static void main(String[] args) {
		System.setProperty("webdriver.chrome.driver", "/PathToChromeDriver/chromedriver");
		WebDriver webDriver = new ChromeDriver();

		webDriver.navigate().to(
				"https://github.com/SeleniumHQ/selenium/blob/ceaf3da79542024becdda5953059dfbb96fb3a90/.idea/androidDexCompiler.xml");

		webDriver.getCurrentUrl();
		System.out.println(webDriver.getCurrentUrl());
		webDriver.quit();
	}

}

dharmakrish6 avatar Feb 19 '18 09:02 dharmakrish6

Hey @dharmakrish6,

thank you, but we already specify the chromedriver executable for the webdriver.chrome.driver property in the maven call (we use the Citrus Test Framework) so this is not the issue.

Driver.getCurrentUrl() works for HTML pages, but not for XML ones.

Kind regards, Nicolas Kogler

ghost avatar Feb 19 '18 13:02 ghost

Driver.getCurrentUrl() works for HTML pages, but not for XML ones

FWIW, the sample link you gave produces HTML, not XML:

$ URL="https://github.com/SeleniumHQ/selenium/blob/ceaf3da79542024becdda5953059dfbb96fb3a90/.idea/androidDexCompiler.xml"
$ curl -s -I $URL | grep "^Content-Type"
Content-Type: text/html; charset=utf-8

cgoldberg avatar Feb 19 '18 15:02 cgoldberg

@NicolasKogler Can you please post the xml link, so that we can try to find the solution.

dharmakrish6 avatar Feb 20 '18 05:02 dharmakrish6

Closing the issue as we didn't get more info from the OP

diemol avatar May 21 '20 19:05 diemol

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jun 24 '20 23:06 lock[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jun 24 '20 23:06 lock[bot]