[selenium-users] [webDriver] HtmlUnitDriver can't find element...Why?

3,205 views
Skip to first unread message

Bauer

unread,
May 12, 2010, 10:29:51 AM5/12/10
to Selenium Users
Hello Friends,
First off, I want to appologize for the length of this post. I
included ALL code and console errors. I know it got lengthy.

I have the "Example" from the Selenium homepage for the HtmlUnitDriver
and it will work on Google's home page as follows:

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class TestHTML
{
@Test
public void test() throws Exception
{
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.google.com");
driver.findElement(By.name("q")).sendKeys("cheese");
driver.findElement(By.name("btnG")).click();
System.out.println("Page title is: " + driver.getTitle());
}
}

The output of this test in the console is as follows:
Page title is: cheese - Google Search

NOW, If I change the site to amazon it will get the page title just
fine while excluding the two middle lines of sendkeys and click btnG.
So the HtmlUnitDriver is working, so i think. Why, then, when I go to
another site it will not work with the following code:

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class TestHTML
{
@Test
public void test() throws Exception
{
WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.SomeSiteWithLogin.com");
driver.findElement(By.name("username")).sendKeys("JohnSmith");
driver.findElement(By.name("pwd")).sendKeys("password");
driver.findElement(By.name("login")).click();
System.out.println("Page title is: " + driver.getTitle());
}
}

*This test will fail on trying to identify the username field.

*If i change the declaration to
HtmlUnitDriver driver = new HtmlUnitDriver();
It is the same as WebDriver, meaning it fails the JUnit test
with same errors.

*If I add the line
driver.setJavascriptEnabled(true);
Is when I get a lot of error messages in the console as seen
at the bottom of this post.

*I have the console output (HtmlUnitDriver) and the JUnit output
following.

The JUnit error occurs no matter WebDriver or HtmlUnitDriver and is
as follows:
********************************************************************************************************
org.openqa.selenium.NoSuchElementException: Cannot find element with
name: client
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_18'
Driver info: driver.version: htmlunit
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByName(HtmlUnitDriver.java:
545)
at org.openqa.selenium.By$4.findElement(By.java:148)
at
org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:
279)
at sandbox.TestHTML.test(TestHTML.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod
$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
73)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:
28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:
31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
197)



The Console output run as HtmlUnitDriver with
setJavaScriptEnabled(true) is as follows:
***********************************************************************************************************
May 12, 2010 10:11:24 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [20:108] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [20:113] Error in style rule. Invalid token
"background-color". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [20:113] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [24:39] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [35:91] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [67:107] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [67:112] Error in style rule. Invalid token
"background-color". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [67:112] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [126:106] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [126:111] Error in style rule. Invalid token
"cursor". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [126:111] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [129:103] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [129:108] Error in style rule. Invalid token
"cursor". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [129:108] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [265:90] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [269:102] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [303:134] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [303:138] Error in style rule. Invalid token
"opacity". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [303:138] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [314:99] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [314:105] Error in style rule. Invalid token
"opacity". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [314:105] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [324:166] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [431:124] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [431:129] Error in style rule. Invalid token
"border-top". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [431:129] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [432:84] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [432:89] Error in style rule. Invalid token
"border". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [432:89] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [438:146] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [438:151] Error in style rule. Invalid token
"zoom". Was expecting one of: "}", ";".

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [438:151] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:25 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [487:102] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [515:187] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [516:89] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [587:28] Error in style rule. Invalid token
":". Was expecting one of: <S>, "}", <COMMA>, ";", "/", <PLUS>, "-",
<HASH>, <STRING>, <URI>, "!", "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [587:28] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [720:145] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [743:76] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [744:182] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [777:120] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [777:125] Error in style rule. Invalid token
"background-color". Was expecting one of: "}", ";".

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
WARNING: CSS warning: null [777:125] Ignoring the following
declarations in this rule.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
WARNING: CSS error: null [849:145] Error in expression. Invalid token
"=". Was expecting one of: <S>, <COMMA>, "/", <PLUS>, "-", <HASH>,
<STRING>, ")", <URI>, "inherit", <EMS>, <EXS>, <LENGTH_PX>,
<LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>,
<ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>,
<FREQ_HZ>, <FREQ_KHZ>, <DIMENSION>, <PERCENTAGE>, <NUMBER>,
<FUNCTION>, <IDENT>.

May 12, 2010 10:11:26 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:27 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:28 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:29 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:29 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.
May 12, 2010 10:11:30 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify

WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:30 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:30 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:30 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

May 12, 2010 10:11:30 AM
com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
WARNING: Obsolete content type encountered: 'text/javascript'.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

ndk

unread,
May 12, 2010, 10:52:55 AM5/12/10
to Selenium Users
I think your problem is that it is not able to find the element
'client' since the error is ,
"Cannot find element with name: client "
Are you sure that the element name "client" exists? Did you try with
driver.findElement(By.id("client")) or something like this? You can
check the id in Selenium IDE recorder or you may want to check your
html source code. You can also use xPath. Firefox has an add-on to
check for xpaths. You can also download IE developer toolbar to find
locators.

Hope this helps,
-ndk

Bauer

unread,
May 12, 2010, 12:00:21 PM5/12/10
to Selenium Users
NDK

I made a little mistake there. I have a test with a few input fields
and client is the first one, username being the second one. For the
mock-up code i excluded parts of my login process to keep it somewhat
shorter. the element named client comes first in my application but
in the above snippet i only showed username. the elements definately
exist because they will work flawlessly with IE and FF drivers.
Sorry about that.

I appologize for that mistake and I also thank you for the quick
reply.

So basically regardless of what I have it named and making sure that
the code in my test is correct, it still won't find the object by
name, ID, or Xpath. I have been looking at this and I can not figure
it out. I am going to attempt to run this on my redhat box and wanted
to use webDriver and I assumed HtmlUnitDriver was the best option
because i don't have a console. I am thinking I may have to use XVFB
or something similar which is the route I will be trying this
afternoon.

thanks again
-Bauer

Bauer

unread,
May 18, 2010, 7:58:55 AM5/18/10
to Selenium Users
So I am thinking that with Java Script enabled:
WebDriver driver = new HtmlUnitDriver(true);

You should be able to accomplish this with most sites. I,
unfortunately am running GWT 1.6 and it seems that I have come to a
dead end.

Ahmed Ashour

unread,
May 18, 2010, 9:11:24 AM5/18/10
to seleniu...@googlegroups.com
Hi Bauer,

All the exception you saw: "WARNING: CSS warning: " and "WARNING: Obsolete content type encountered", can be safely ignored.

Please provide a public website that shows your error, or better minimal test case that shows this behavior.

Yours,
Ahmed
----
Blog: http://asashour.blogspot.com

From: Bauer <chris...@gmail.com>
To: Selenium Users <seleniu...@googlegroups.com>
Sent: Tue, May 18, 2010 2:58:55 PM
Subject: [selenium-users] Re: [webDriver] HtmlUnitDriver can't find element...Why?

So I am thinking that with Java Script enabled:
WebDriver driver = new HtmlUnitDriver(true);

You should be able to accomplish this with most sites.  I,
unfortunately am running GWT 1.6 and it seems that I have come to a
dead end.

-Bauer

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Bauer

unread,
May 18, 2010, 4:21:04 PM5/18/10
to Selenium Users
Ahmed,
Here is a brief code example showing my dilemma. On the site in the
code, HtmlUnitDriver will NOT find the "Level +" button. It doesn't
have a name so I found it by Xpath and verified that the xpath is
correct because it will run with firefoxDriver.

//button[contains(.,'Level +')]

package sandbox;


import junit.framework.TestCase;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;


public class TestGWT extends TestCase
{
@Test
public void test() throws Exception
{
//WebDriver driver = new FirefoxDriver(); //This works
WebDriver driver = new HtmlUnitDriver(); //this does NOT work
driver.get("http://www.brainboffin.com/");
Thread.sleep(3500); //for simplicity
driver.findElement(By.xpath("//button[contains(.,'Level
+')]")).click();
Thread.sleep(2500); //to visually see it clicked the button with
firefox
System.out.println("Page title is: " + driver.getTitle());

driver.close();
driver.quit();
}
}


There is a code snippet that will not find the button with
HtmlUnitDriver but will do just fine with FirefoxDriver. thanks for
your replies and looking into the issue for me. It is greatly
appreciated.

-Bauer

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.

Ahmed Ashour

unread,
May 18, 2010, 6:17:24 PM5/18/10
to seleniu...@googlegroups.com
Hi Bauer,

With directly using HtmlUnit, obviously it doesn't correctly load the page as compared to FF.

It will be much appreciated if you can provide the GWT application with '-style PRETTY', to debug it further.

In any case, please open a bug repot in HtmlUnit tracker.


        WebClient client = new WebClient(BrowserVersion.FIREFOX_3);
        HtmlPage page = client.getPage("http://www.brainboffin.com/");
        Thread.sleep(20000);
        System.out.println(page.asXml());


Yours,
Ahmed
----
Blog: http://asashour.blogspot.com

From: Bauer <chris...@gmail.com>
To: Selenium Users <seleniu...@googlegroups.com>
Sent: Tue, May 18, 2010 11:21:04 PM

Subject: [selenium-users] Re: [webDriver] HtmlUnitDriver can't find element...Why?
To unsubscribe from this group, send email to selenium-users+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Bauer

unread,
May 19, 2010, 4:11:19 PM5/19/10
to Selenium Users
Ahmed,

I submitted the bug tracker. I will be out of the office until
monday. i got your reply within the tracker and didn't want to
clutter it up with useless stuff so i am replying here. I am not sure
what the -style Pretty is, so I will look into that and how to use it
when i return to the office. I will try to do anything I can possibly
do to help you make this work. I am completely willing to get you
what you need to the best of my ability.

Thanks you again for your time and consideration of my issue.

-Bauer

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.

lisa lee

unread,
Aug 5, 2013, 11:18:57 PM8/5/13
to seleniu...@googlegroups.com, chris...@gmail.com
Hello All,

Is there a solution or workaround for this?

Looking forward to your replay.

Thank you,
Lisa

Krishnan Mahadevan

unread,
Aug 6, 2013, 3:23:46 AM8/6/13
to Selenium Users
Lisa,

You ended up reviving a thread that is more than 2 years old. 
So what is the issue you are facing now ? It would help if you could add a bit more context around this.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages