Skip to content

Commit 527e0d6

Browse files
Merge pull request #440 from TikhomirovSergey/setValue
The setValue method was moved to MobileElement.
2 parents 36f7dcf + 0c38937 commit 527e0d6

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

src/main/java/io/appium/java_client/MobileElement.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.appium.java_client;
1818

19+
import com.google.common.collect.ImmutableMap;
20+
1921
import org.openqa.selenium.By;
2022
import org.openqa.selenium.Dimension;
2123
import org.openqa.selenium.Point;
@@ -106,4 +108,16 @@ public List<MobileElement> findElementsByXPath(String using) {
106108
@Override public List<MobileElement> findElementsByAccessibilityId(String using) {
107109
return super.findElementsByAccessibilityId(using);
108110
}
111+
112+
/**
113+
* This method sets the new value of the attribute "value".
114+
*
115+
* @param value is the new value which should be set
116+
*/
117+
@SuppressWarnings({"rawtypes", "unchecked"})
118+
public void setValue(String value) {
119+
ImmutableMap.Builder builder = ImmutableMap.builder();
120+
builder.put("id", id).put("value", value);
121+
execute(MobileCommand.SET_VALUE, builder.build());
122+
}
109123
}

src/main/java/io/appium/java_client/ios/IOSElement.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
package io.appium.java_client.ios;
1818

19-
import com.google.common.collect.ImmutableMap;
20-
2119
import io.appium.java_client.FindsByIosUIAutomation;
22-
import io.appium.java_client.MobileCommand;
2320
import io.appium.java_client.MobileElement;
2421
import org.openqa.selenium.WebDriverException;
2522

@@ -44,16 +41,4 @@ public class IOSElement extends MobileElement
4441
throws WebDriverException {
4542
return findElements("-ios uiautomation", using);
4643
}
47-
48-
/**
49-
* This method sets the new value of the attribute "value".
50-
*
51-
* @param value is the new value which should be set
52-
*/
53-
@SuppressWarnings({"rawtypes", "unchecked"})
54-
public void setValue(String value) {
55-
ImmutableMap.Builder builder = ImmutableMap.builder();
56-
builder.put("id", id).put("value", value);
57-
execute(MobileCommand.SET_VALUE, builder.build());
58-
}
5944
}

src/test/java/io/appium/java_client/android/AndroidElementTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,14 @@ public class AndroidElementTest extends BaseAndroidTest {
7474
+ "new UiSelector().text(\"Radio Group\"));"));
7575
assertNotNull(radioGroup.getLocation());
7676
}
77+
78+
@Test public void setValueTest() {
79+
String value = "new value";
80+
81+
driver.startActivity("io.appium.android.apis", ".view.Controls1");
82+
AndroidElement editElement = driver
83+
.findElementByAndroidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")");
84+
editElement.setValue(value);
85+
assertEquals(value, editElement.getText());
86+
}
7787
}

0 commit comments

Comments
 (0)