0

I have already tried multiple codes(using java) to clear password field of my android application such as,

driver.findElement(By.id("..")).clear();
driver.findElement(By.id("..")).sendKeys(" ");

Also i tried all the answers given in below link,

Appium : Clear a field

But nothing does work for me.

I'm trying to automate my android application using Appium 1.4.13.

Community
  • 1
  • 1
Disha
  • 49
  • 11

2 Answers2

0

Try this code !

WebElement element=appiumDriver.findElement(By.xpath("xpathString"));
element.click();
element.sendKeys(Keys.CONTROL + "a");
element.sendKeys(Keys.DELETE);
Devdutta Goyal
  • 985
  • 2
  • 11
  • 27
  • Thanks for your quick response. I applied your code but again the same, click & select commands are working but not delete one. Now i am thinking, if nothing works for me, it should be something else like appium version or any library i could miss! – Disha Mar 25 '17 at 05:10
  • Hey Harsh, unfortunately backspace is also not working – Disha Mar 25 '17 at 09:16
  • Hi Disha, i was facing the same issue and implemented helper for that, wait upto Monday because code is in my office PC – Devdutta Goyal Mar 25 '17 at 10:26
  • Hi Harsh, Did you find any solution for this? – Disha Mar 27 '17 at 06:39
  • Hi Disha, Try this code in the same sequence as given 1) driver.findElement().clear; 2) driver.findElement().click 3) driver.findElement().sendKeys(""); – Devdutta Goyal Mar 27 '17 at 19:08
0

You have to simply use

driver.findElement(By.id("com.example.jiteshmohite.ycce:id/password")).clear();

check your xpath id and make sure it is correct.

Here is my code which works for me.

        // Create object of DesiredCapabilities class

        DesiredCapabilities capabilities = new DesiredCapabilities();

        // Optional

        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");

        // Specify the device name (any name)

        capabilities.setCapability("deviceName", "My New Phone");

        // Platform version

        capabilities.setCapability("platformVersion", "4.4.2");

        // platform name

        capabilities.setCapability("platformName", "Android");

        // specify the application package that we copied from appium

        capabilities.setCapability("appPackage", "com.example.jiteshmohite.ycce");

        // specify the application activity that we copied from appium

        capabilities.setCapability("appActivity", ".LoginActivity");

        // Start android driver I used 4727 port by default it will be 4723

        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

        // Specify the implicit wait of 5 second
//
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);


        driver.findElement(By.id("com.example.jiteshmohite.ycce:id/password")).clear();
Jitesh Mohite
  • 31,138
  • 12
  • 157
  • 147
  • I have tried with id & xpath both, both are correct as with the same field, other functions are working perfectly. If this command works for you, can you just provide me the details of all the required libraries & tools(such as appium, java-client,android sdk,mac os,selenium standalone server etc)you used with version number? – Disha Mar 27 '17 at 13:35