Skip to content

Commit bee2b76

Browse files
Added logElement method in order to set if you wants print element
information, such as: position, size, tag name, etc.
1 parent 0f8d7f8 commit bee2b76

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/main/java/com/mobilebox/repl/commands/AppiumCommands.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.openqa.selenium.WebElement;
3030
import org.openqa.selenium.remote.DesiredCapabilities;
3131

32+
import com.mobilebox.repl.Appium;
3233
import com.mobilebox.repl.config.ConfigCapabilities;
3334
import com.mobilebox.repl.exceptions.CommandsException;
3435

@@ -43,6 +44,7 @@ public abstract class AppiumCommands<T extends AppiumDriver, E extends WebElemen
4344
private String app;
4445
private AppiumDriver<E> driver;
4546
private final String ENGINE_NAME = "nashorn";
47+
private boolean logElement = true;
4648

4749
abstract void start(String deviceName, String udid, String app, String server, String timeout)
4850
throws CommandsException, MalformedURLException;
@@ -147,6 +149,10 @@ protected void setDeviceID(String id) {
147149
protected void setApp(String app) {
148150
this.app = app;
149151
};
152+
153+
public void logElement(boolean log){
154+
logElement = log;
155+
}
150156

151157
@CommandRef(desc = "Terminates the driver instance.")
152158
public void quit() {
@@ -273,16 +279,18 @@ protected List<E> findElements(By locator) {
273279
}
274280

275281
protected void printElement(E element) {
276-
Point location = element.getLocation();
277-
Dimension size = element.getSize();
278-
console("---> Text: " + element.getText());
279-
console("---> TagName: " + element.getTagName());
280-
console("---> Enabled: " + element.isEnabled());
281-
console("---> Selected: " + element.isSelected());
282-
console("---> Displayed: " + element.isDisplayed());
283-
console("---> Location: [X=" + location.getX() + " Y=" + location.getY() + "]");
284-
console(
285-
"---> Size: [Height=" + size.getHeight() + " Width=" + size.getWidth() + "]" + SEPARATOR);
282+
if (logElement) {
283+
Point location = element.getLocation();
284+
Dimension size = element.getSize();
285+
console("---> Text: " + element.getText());
286+
console("---> TagName: " + element.getTagName());
287+
console("---> Enabled: " + element.isEnabled());
288+
console("---> Selected: " + element.isSelected());
289+
console("---> Displayed: " + element.isDisplayed());
290+
console("---> Location: [X=" + location.getX() + " Y=" + location.getY() + "]");
291+
console(
292+
"---> Size: [Height=" + size.getHeight() + " Width=" + size.getWidth() + "]" + SEPARATOR);
293+
}
286294
}
287295

288296
private void setPlatformName(final String platform, URL urlServer, DesiredCapabilities caps) {

0 commit comments

Comments
 (0)