Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Unit driver is always defaulting to IE8 #86

Open
arjunkapur95 opened this issue Apr 22, 2020 · 3 comments
Open

HTML Unit driver is always defaulting to IE8 #86

arjunkapur95 opened this issue Apr 22, 2020 · 3 comments

Comments

@arjunkapur95
Copy link

arjunkapur95 commented Apr 22, 2020

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.

@rbri
Copy link
Collaborator

rbri commented Apr 27, 2020

To work together with Selenium 3.141.59 you need at least HtmlUnitDriver 2.33.3.
But of course you it will be the best to use the latest HtmlUnitDriver version (at the moment 2.39.0).

Have a look at https://github.com/SeleniumHQ/htmlunit-driver/releases for more.

@arjunkapur95
Copy link
Author

To work together with Selenium 3.141.59 you need at least HtmlUnitDriver 2.33.3.
But of course you it will be the best to use the latest HtmlUnitDriver version (at the moment 2.39.0).

Have a look at https://github.com/SeleniumHQ/htmlunit-driver/releases for more.

Hey rbri,

As per your suggestion, i updated my POM to 2.39.0 but I still default to IE8 .

I am not sure If I am doing something wrong but to replicate this i opened the website using IE8 emulation and I am getting the same error as before. Sharing Image for your reference.

image

Additionally sharing the Url for you to confirm if this issue persists on your end when you open the URL through HtmlUnitDriver.

https://reflectionsstaging.optisolbusiness.com/#!/login

@rbri
Copy link
Collaborator

rbri commented May 1, 2020

Sorry, now i got your point. In your case i guess HtmlUnit & the Driver are doing the right thing but the page has some kind of browser checking. This is usually done based on some js feature checks. Will have a look if i can find the reason for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants