Issue 2522 in selenium: Asserting specific table cell value using nth-child and ntf-of-type, chromedriver

5 views
Skip to first unread message

sele...@googlecode.com

unread,
Sep 22, 2011, 3:22:46 AM9/22/11
to selenium-deve...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2522 by aleksi....@enersize.com: Asserting specific table
cell value using nth-child and ntf-of-type, chromedriver
http://code.google.com/p/selenium/issues/detail?id=2522

What steps will reproduce the problem?
1. Trying to assert value on a specific table using nth-child or nth-of-type
2.
3.

What is the expected output? What do you see instead?
I try to assert value on a certain table cell and these both examples work
with firefox driver, no problem. But in chrome driver in both cases driver
finds the first element value right but none after that. I've already found
an alternative way to do this task and only interested on the reason that
is making this happen, is it a defect on chrome driver or something else?


Selenium version: 2.6.0
OS: Mac OSX 10.6.8
Browser: Google Chrome
Browser version: 14.0.835.186
ChromeDriver version: 14.0.836.0


Additional info:

Here is the assertions and error stacktraces:

First case:

assertEquals( browserDriver.getName(), String expected,
driver.findElement(
By.cssSelector( ".display>tbody>tr:nth-child(3)>td:nth-of-type(2)" )
).getText() );
assertEquals( browserDriver.getName(), String expected,
driver.findElement(
By.cssSelector( ".display>tbody>tr:nth-child(3)>td:nth-of-type(3)" )
).getText() );

Stacktrace:
org.junit.experimental.theories.internal.ParameterizedAssertionError:
testListNotifications(getBrowserDrivers[1])
at
org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:176)
at
org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:131)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:112)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:96)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:105)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:94)
at
org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:82)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
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)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate
element (WARNING: The server did not provide any stacktrace information);
duration or timeout: 66 milliseconds
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.6.0', revision: '13840', time: '2011-09-13 16:51:41'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.6.8',
java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:397)
at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:182)
at
org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:247)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:400)
at
org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:174)
at
com.enersize.app.action.secure.systemtools.NotificationAdminActionTest.testListNotifications(NotificationAdminActionTest.java:66)
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.experimental.theories.Theories$TheoryAnchor$2.evaluate(Theories.java:160)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:126)
... 20 more


Second case:

assertTrue( browserDriver.getName(),
isTextInElement( ".display>tbody>tr:nth-child(3)>td:nth-child(3)", String
expected ) );
assertTrue( browserDriver.getName(),
isTextInElement( ".display>tbody>tr:nth-child(3)>td:nth-child(2)", String
expected ) );

private boolean isTextInElementImpl( final String identifier, final String
text )
{
List<WebElement> elements = driver.findElements( By.cssSelector(
identifier ) );

for( WebElement ele : elements )
{
if( ele.getText().equals( text ) )
{
return true;
}
}
return false;
}

Stacktrace:
org.junit.experimental.theories.internal.ParameterizedAssertionError:
testListNotifications(getBrowserDrivers[1])
at
org.junit.experimental.theories.Theories$TheoryAnchor.reportParameterizedError(Theories.java:176)
at
org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:131)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithCompleteAssignment(Theories.java:112)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:96)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithIncompleteAssignment(Theories.java:105)
at
org.junit.experimental.theories.Theories$TheoryAnchor.runWithAssignment(Theories.java:94)
at
org.junit.experimental.theories.Theories$TheoryAnchor.evaluate(Theories.java:82)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
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)
Caused by: java.lang.AssertionError: ChromeDriver
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.assertTrue(Assert.java:43)
at
com.enersize.app.action.secure.systemtools.NotificationAdminActionTest.testListNotifications(NotificationAdminActionTest.java:64)
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.experimental.theories.Theories$TheoryAnchor$2.evaluate(Theories.java:160)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.experimental.theories.Theories$TheoryAnchor$1$1.evaluate(Theories.java:126)
... 20 more

ChromeDriver.log is empty


sele...@googlecode.com

unread,
Sep 22, 2011, 2:24:52 PM9/22/11
to selenium-deve...@googlegroups.com
Updates:
Status: NeedsClarification
Labels: Browser-Chrome

Comment #1 on issue 2522 by barancev: Asserting specific table cell value

using nth-child and ntf-of-type, chromedriver
http://code.google.com/p/selenium/issues/detail?id=2522

Please supply us with the test-case you're trying to execute, either
against a publicly accessible site, or with the HTML it's running against.

It may be either page-specific, or MacOS-specific. The following sample
works on Win7 + Chrome 14.0.835.186:


@Test
public void test() throws Exception {
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("http://www.w3schools.com/html/html_tables.asp");
Assert.assertEquals("Oranges",
driver.findElement(By.cssSelector(".reference>tbody>tr:nth-child(3)>td:nth-of-type(1)")).getText());
Assert.assertEquals("13%",
driver.findElement(By.cssSelector(".reference>tbody>tr:nth-child(3)>td:nth-of-type(2)")).getText());
driver.quit();
}


sele...@googlecode.com

unread,
Sep 23, 2011, 2:29:06 AM9/23/11
to selenium-deve...@googlegroups.com

Comment #2 on issue 2522 by aleksi....@enersize.com: Asserting specific
table cell value using nth-child and ntf-of-type, chromedriver
http://code.google.com/p/selenium/issues/detail?id=2522

This is the test case i want to run against the attached html and it fails
with chrome to find element on the second assertEquals.

@Theory
public void testListNotification( BrowserDriver browserDriver ) throws
Exception
{
setBrowserDriver( browserDriver );
driver.get("http://localhost/static/issue/testTableNthChild.html");
waitElementWithBy( By.id( "notificationContent" ) );
Assert.assertEquals( browserDriver.getName(), "Notifications",
driver.findElement( By.cssSelector( "#notificationContent>h4" ) ).getText()
);

Assert.assertEquals( browserDriver.getName(), "", driver.findElement(
By.cssSelector( "#accFilter" ) ).getAttribute( "value" ) );
Assert.assertEquals( browserDriver.getName(), 5, getRowCount(
By.cssSelector( ".display") ) );

Assert.assertEquals( browserDriver.getName(), "2009/05/08 22:44",
driver.findElement(
By.cssSelector( ".display>tbody>tr:nth-child(3)>td:nth-child(1)" )
).getText() );
//Next assertEquals will fail in chrome although it works fine in firefox
Assert.assertEquals( browserDriver.getName(), "Alert",
driver.findElement(
By.cssSelector( ".display>tbody>tr:nth-child(3)>td:nth-child(3)" )
).getText() );
}

Attachments:
testTableNthChild.html 1.2 KB

sele...@googlecode.com

unread,
Oct 4, 2011, 2:06:13 AM10/4/11
to selenium-deve...@googlegroups.com
Updates:
Status: Accepted
Labels: Component-WebDriver

Comment #3 on issue 2522 by barancev: Asserting specific table cell value

using nth-child and ntf-of-type, chromedriver
http://code.google.com/p/selenium/issues/detail?id=2522

Yes, I've reproduced it with the sample attached, thanks!

Reply all
Reply to author
Forward
0 new messages