From 885ef208389b18d02ce9ec5b5609243bc414605c Mon Sep 17 00:00:00 2001 From: "SEAVUS-CORP\\Margarita.Jankovska" Date: Thu, 23 Feb 2017 16:07:33 +0100 Subject: [PATCH] Issue with getting text from --- test/java/build.gradle | 2 ++ .../java/ghostdriver/GhostDriverIssue.java | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/java/src/test/java/ghostdriver/GhostDriverIssue.java diff --git a/test/java/build.gradle b/test/java/build.gradle index 56aa4712b..05cc5b0b4 100644 --- a/test/java/build.gradle +++ b/test/java/build.gradle @@ -62,6 +62,8 @@ dependencies { // Library under test (PhantomJS Driver, aka "PhantomJS WebDriver Java Binding") testCompile files("../../binding/java/jars/phantomjsdriver-${phantomjsdriverVersion}.jar") // testCompile "com.codeborne:phantomjsdriver:$phantomjsdriverVersion" + + testCompile 'org.assertj:assertj-core:3.6.2' } tasks.withType(JavaExec) { diff --git a/test/java/src/test/java/ghostdriver/GhostDriverIssue.java b/test/java/src/test/java/ghostdriver/GhostDriverIssue.java new file mode 100644 index 000000000..1c3c3bee5 --- /dev/null +++ b/test/java/src/test/java/ghostdriver/GhostDriverIssue.java @@ -0,0 +1,32 @@ +package ghostdriver; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.phantomjs.PhantomJSDriver; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.remote.RemoteWebDriver; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GhostDriverIssue { + + @Test + public void demonstrateIssue() { + DesiredCapabilities capabilities = DesiredCapabilities.chrome(); + capabilities.setJavascriptEnabled(true); + RemoteWebDriver driver = new PhantomJSDriver(capabilities); + + driver.get("http://www.turkpatent.gov.tr/TurkPatent/attorneysearchAll/"); + + List rows = driver.findElement(By.cssSelector("[id='t01']")).findElements(By.cssSelector("tr")); + + int rowIndex = 1; // skip header. + List row = rows.get(rowIndex).findElements(By.cssSelector("td")); + assertThat(row.size()).isEqualTo(7); // all cells are found. + assertThat(row.get(2).getText()).isNotEmpty(); // 'Vekil Firma' is found. + assertThat(row.get(4).getText()).isNotEmpty(); // but cannot read the next cell's text - 'Vekil Adres'. + } +} \ No newline at end of file