SeleniumHQ / SeleniumHQ/htmlunit-driver

HTML Unit driver is always defaulting to IE8

Open
#86 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
266
Forks
91
PR merge metrics
No merged PRs in 30d

Description

Hi so irrespective of me mentioning the browser version upon creating a HtmlDriver instance the driver is always defaulting to IE8

My Pom File
`
4.0.0

<groupId>basic-web-appJenkins</groupId>
<artifactId>jenkins</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>jenkins</name>
<url>http://maven.apache.org</url>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>1.5.6.RELEASE</version>
	<relativePath />
</parent>
<dependencies>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.8.1</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>com.applitools</groupId>
		<artifactId>eyes-selenium-java3</artifactId>
		<version>RELEASE</version>
	</dependency>
	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-java</artifactId>
		<version>3.141.59</version>
	</dependency>
	<dependency>
		<groupId>org.freemarker</groupId>
		<artifactId>freemarker</artifactId>
		<version>2.3.23</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<version>2.7.4</version>
		<exclusions>
			<exclusion>
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-core</artifactId>
			</exclusion>
			<exclusion>
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-annotations</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-core</artifactId>
		<version>2.7.4</version>
	</dependency>
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-annotations</artifactId>
		<version>2.7.4</version>
	</dependency>
	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>htmlunit-driver</artifactId>
		<version>2.20</version>
	</dependency>
</dependencies>

<repositories>
	<repository>
		<id>spring-snapshots</id>
		<name>Spring Snapshots</name>
		<url>http://repo.spring.io/libs-snapshot-local</url>
		<snapshots>
			<enabled>true</enabled>
		</snapshots>
	</repository>
	<repository>
		<id>spring-milestones</id>
		<name>Spring Milestones</name>
		<url>http://repo.spring.io/libs-milestone-local</url>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</repository>
	<repository>
		<id>spring-releases</id>
		<name>Spring Releases</name>
		<url>http://repo.spring.io/libs-release-local</url>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</repository>
</repositories>

`

My Test Case
`@Test
public void testLoginCorrectCredentialsCorrect() throws Exception {

	WebDriver webDriver = new HtmlUnitDriver(BrowserVersion.CHROME, true) {
	    @Override
	    protected WebClient modifyWebClient(WebClient client) {
	        final WebClient webClient = super.modifyWebClient(client);
	        // you might customize the client here
	        webClient.getOptions().setCssEnabled(false);

	       return webClient;
	    }
	};
	
	webDriver.get("https://reflectionsstaging.optisolbusiness.com");// step 2 web driver navigation
	

	//ReflectionHome webElements = new ReflectionHome(webDriver);
	
	if (webDriver.getTitle().equals("Reflection"))// step 3 locating an element
	{
		System.out.println(webDriver.getPageSource());
		
		WebDriverWait wait = new WebDriverWait(webDriver,30);
		wait.until(ExpectedConditions.elementToBeClickable(By.name("email")));
		webDriver.findElement(By.name("email")).sendKeys("yopmail.com"); // step 4,5 wait for return from the															// browser
		webDriver.findElement(By.name("password")).sendKeys("123");
	
		
		
		
		
		// driver.findElement(By.linkText("Inventory Master")).click();
		// driver.findElement(webElements.inventoryListItem).click();
	} else {
		fail("tes failed");
	
	}
}`

My Imports:
import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.WebClient;

The output I get from page source where I verify that IE8 was called(obtained by using the getpagesource function)

image

If you notice in this output that I have shared IE8 is the browser that is being called. I opened IE Edge and emulated to see that my site does indeed throw the above error message in IE8 only. Would someone have a look at it and let me know how i can go about fixing this.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HtmlUnitDriver(BrowserVersion.CHROME, true) construction and the modifyWebClient override shown in the test case, then inspect how the selected BrowserVersion is passed to the underlying client. Reproduce the navigation and page-source output, and verify that the resulting user-agent behavior no longer identifies the browser as IE8.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.