Skip to content

Commit 5716c25

Browse files
committed
Replace getAttribute() with getDomProperty() in all example
1 parent e7ef8db commit 5716c25

File tree

76 files changed

+116
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+116
-116
lines changed

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/keyboard/SendKeysJUnit4Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public void testSendKeys() {
5454
WebElement inputText = driver.findElement(By.name("my-text"));
5555
String textValue = "Hello World!";
5656
inputText.sendKeys(textValue);
57-
assertThat(inputText.getAttribute("value")).isEqualTo(textValue);
57+
assertThat(inputText.getDomProperty("value")).isEqualTo(textValue);
5858

5959
inputText.clear();
60-
assertThat(inputText.getAttribute("value")).isEmpty();
60+
assertThat(inputText.getDomProperty("value")).isEmpty();
6161
}
6262

6363
}

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/keyboard/SliderJUnit4Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public void testSlider() {
5858
"https://bonigarcia.dev/selenium-webdriver-java/web-form.html");
5959

6060
WebElement slider = driver.findElement(By.name("my-range"));
61-
String initValue = slider.getAttribute("value");
61+
String initValue = slider.getDomProperty("value");
6262
log.debug("The initial value of the slider is {}", initValue);
6363

6464
for (int i = 0; i < 5; i++) {
6565
slider.sendKeys(Keys.ARROW_RIGHT);
6666
}
6767

68-
String endValue = slider.getAttribute("value");
68+
String endValue = slider.getDomProperty("value");
6969
log.debug("The final value of the slider is {}", endValue);
7070
assertThat(initValue).isNotEqualTo(endValue);
7171
}

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/locators/ByCssSelectorJUnit4Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ public void testByCssSelectorAdvanced() {
6565

6666
WebElement checkbox1 = driver
6767
.findElement(By.cssSelector("[type=checkbox]:checked"));
68-
assertThat(checkbox1.getAttribute("id")).isEqualTo("my-check-1");
68+
assertThat(checkbox1.getDomProperty("id")).isEqualTo("my-check-1");
6969
assertThat(checkbox1.isSelected()).isTrue();
7070

7171
WebElement checkbox2 = driver
7272
.findElement(By.cssSelector("[type=checkbox]:not(:checked)"));
73-
assertThat(checkbox2.getAttribute("id")).isEqualTo("my-check-2");
73+
assertThat(checkbox2.getDomProperty("id")).isEqualTo("my-check-2");
7474
assertThat(checkbox2.isSelected()).isFalse();
7575
}
7676

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/locators/ByHtmlAttributesJUnit4Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ public void testByHtmlAttributes() {
5454

5555
// By id
5656
WebElement textById = driver.findElement(By.id("my-text-id"));
57-
assertThat(textById.getAttribute("type")).isEqualTo("text");
57+
assertThat(textById.getDomProperty("type")).isEqualTo("text");
5858
assertThat(textById.getDomAttribute("type")).isEqualTo("text");
5959
assertThat(textById.getDomProperty("type")).isEqualTo("text");
6060

61-
assertThat(textById.getAttribute("myprop")).isEqualTo("myvalue");
61+
assertThat(textById.getDomProperty("myprop")).isEqualTo("myvalue");
6262
assertThat(textById.getDomAttribute("myprop")).isEqualTo("myvalue");
6363
assertThat(textById.getDomProperty("myprop")).isNull();
6464

6565
// By public class name
6666
List<WebElement> byClassName = driver
6767
.findElements(By.className("form-control"));
6868
assertThat(byClassName.size()).isPositive();
69-
assertThat(byClassName.get(0).getAttribute("name"))
69+
assertThat(byClassName.get(0).getDomProperty("name"))
7070
.isEqualTo("my-text");
7171
}
7272

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/locators/ByXPathJUnit4Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ public void testByXPathAdvanced() {
6565

6666
WebElement radio1 = driver
6767
.findElement(By.xpath("//*[@type='radio' and @checked]"));
68-
assertThat(radio1.getAttribute("id")).isEqualTo("my-radio-1");
68+
assertThat(radio1.getDomProperty("id")).isEqualTo("my-radio-1");
6969
assertThat(radio1.isSelected()).isTrue();
7070

7171
WebElement radio2 = driver
7272
.findElement(By.xpath("//*[@type='radio' and not(@checked)]"));
73-
assertThat(radio2.getAttribute("id")).isEqualTo("my-radio-2");
73+
assertThat(radio2.getDomProperty("id")).isEqualTo("my-radio-2");
7474
assertThat(radio2.isSelected()).isFalse();
7575
}
7676

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/locators_compound/ByIdOrNameJUnit4Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public void testByIdOrName() {
4747
"https://bonigarcia.dev/selenium-webdriver-java/web-form.html");
4848

4949
WebElement fileElement = driver.findElement(new ByIdOrName("my-file"));
50-
assertThat(fileElement.getAttribute("id")).isBlank();
51-
assertThat(fileElement.getAttribute("name")).isNotBlank();
50+
assertThat(fileElement.getDomProperty("id")).isBlank();
51+
assertThat(fileElement.getDomProperty("name")).isNotBlank();
5252
}
5353

5454
}

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/locators_relative/DatePickerJUnit4Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void testDatePicker() {
8585
dayElement.click();
8686

8787
// Get the final date on the input text
88-
String oneYearBack = datePicker.getAttribute("value");
88+
String oneYearBack = datePicker.getDomProperty("value");
8989
log.debug("Final date in date picker: {}", oneYearBack);
9090

9191
// Assert that the expected date is equal to the one selected in the

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/locators_relative/RelativeLocatorsJUnit4Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testRelativeLocators() {
5151
WebElement link = driver.findElement(By.linkText("Return to index"));
5252
RelativeBy relativeBy = RelativeLocator.with(By.tagName("input"));
5353
WebElement readOnly = driver.findElement(relativeBy.above(link));
54-
assertThat(readOnly.getAttribute("name")).isEqualTo("my-readonly");
54+
assertThat(readOnly.getDomProperty("name")).isEqualTo("my-readonly");
5555
}
5656

5757
}

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/user_gestures/CopyAndPasteJUnit4Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public void testCopyAndPaste() {
6363
.sendKeys(inputText, "a").sendKeys(inputText, "c")
6464
.sendKeys(textarea, "v").build().perform();
6565

66-
assertThat(inputText.getAttribute("value"))
67-
.isEqualTo(textarea.getAttribute("value"));
66+
assertThat(inputText.getDomProperty("value"))
67+
.isEqualTo(textarea.getDomProperty("value"));
6868
}
6969

7070
}

selenium-webdriver-junit4/src/test/java/io/github/bonigarcia/webdriver/junit4/ch03/wait/ExplicitWaitJUnit4Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testExplicitWait() {
5353

5454
WebElement landscape = wait.until(ExpectedConditions
5555
.presenceOfElementLocated(By.id("landscape")));
56-
assertThat(landscape.getAttribute("src"))
56+
assertThat(landscape.getDomProperty("src"))
5757
.containsIgnoringCase("landscape");
5858
}
5959

0 commit comments

Comments
 (0)