@@ -23,7 +23,6 @@ import org.openqa.selenium.WebDriver;
23
23
import org.openqa.selenium.WebElement;
24
24
import org.openqa.selenium.firefox.FirefoxDriver;
25
25
import org.openqa.selenium.support.ui.WebDriverWait;
26
-
27
26
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;
28
27
29
28
public class HelloSelenium {
@@ -34,8 +33,8 @@ public class HelloSelenium {
34
33
try {
35
34
driver.get("https://google.com/ncr");
36
35
driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER);
37
- WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>a ")));
38
- System.out.println(firstResult.getText( ));
36
+ WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>div ")));
37
+ System.out.println(firstResult.getAttribute("textContent" ));
39
38
} finally {
40
39
driver.quit();
41
40
}
@@ -54,8 +53,8 @@ with webdriver.Firefox() as driver:
54
53
wait = WebDriverWait(driver, 10)
55
54
driver.get("https://google.com/ncr ")
56
55
driver.find_element_by_name("q").send_keys("cheese" + Keys.RETURN)
57
- first_result = wait.until(presence_of_element_located((By.CSS_SELECTOR, "h3>a ")))
58
- print(first_result.text )
56
+ first_result = wait.until(presence_of_element_located((By.CSS_SELECTOR, "h3>div ")))
57
+ print(first_result.get_attribute("textContent") )
59
58
{{< / code-panel >}}
60
59
{{< code-panel language="csharp" >}}
61
60
using System;
@@ -109,6 +108,31 @@ const {Builder, By, Key, until} = require('selenium-webdriver');
109
108
}
110
109
})();
111
110
{{< / code-panel >}}
111
+ {{< code-panel language="kotlin" >}}
112
+ import org.openqa.selenium.By
113
+ import org.openqa.selenium.Keys
114
+ import org.openqa.selenium.WebDriver
115
+ import org.openqa.selenium.WebElement
116
+ import org.openqa.selenium.firefox.FirefoxDriver
117
+ import org.openqa.selenium.support.ui.WebDriverWait
118
+ import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated
119
+
120
+ class HelloSelenium {
121
+
122
+ public main(args: Array<String>) {
123
+ val driver = new FirefoxDriver()
124
+ val wait = new WebDriverWait(driver, 10)
125
+ try {
126
+ driver.get("https://google.com/ncr")
127
+ driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER)
128
+ val firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>div")))
129
+ System.out.println(firstResult.getAttribute("textContent"))
130
+ } finally {
131
+ driver.quit()
132
+ }
133
+ }
134
+ }
135
+ {{< / code-panel >}}
112
136
{{< / code-tab >}}
113
137
114
138
0 commit comments