1

I'm trying to use WinAppDriver and Java. Any simple excercise was gone and I tried to automate Excel. But I have a problem to serf between cells. This is my code:

System.out.println("Before Заполнить яч A5");
exSession.findElementByAccessibilityId("A5").click();
exSession.findElementByAccessibilityId("FormulaBar").sendKeys("10");

exSession.findElementByAccessibilityId("B7").click();
exSession.findElementByAccessibilityId("FormulaBar").sendKeys("20");

System.out.println("Before Заполнить яч B8");
exSession.findElementByAccessibilityId("B8").sendKeys("30");

Here I want to put diff info to the cells of Excel: "10" to A5 cell, "20" put to B7 cell and "30" put to B8 cell.

In result - all of them was put to A5 cell, like this:

10+B72030

How to move from one cell to another?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Vladimir
  • 21
  • 2

1 Answers1

1

I have solved this problem by such code:

    WebElement elementFormulaBar = exSession.findElementByAccessibilityId("FormulaBar");
    WebElement elementB7 = exSession.findElementByName("\"B\" 7");
    addAct.doubleClick(elementB7).build().perform();
    elementFormulaBar.click();
    elementFormulaBar.sendKeys("20");

Fitstly, it's need to make DOUBLECLICK in cell chosen for modification. Secondly, make a click on formula Bar and Thirdly, to enter your symbols (or read cells content).

And ... declaration of addAct variable (I make it as a CLASS variable):

    Actions addAct = new Actions(exSession);

Look at one frame to work with this lines. To start working with EXCEL I used such code:

    @BeforeClass
public static void setUp() {
    try {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("app","C:/Program Files/Microsoft Office/root/Office16/excel.exe");  // "C:\\Windows\\System32\\mspaint.exe");  // "C:\\Windows\\System32\\notepad.exe"); //
        capabilities.setCapability("platformName", "Windows");
        capabilities.setCapability("deviceName", "WindowsPC");
        exSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
        exSession.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        wait = new WebDriverWait(exSession, 5);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

... and use WinAppDriver and WinAppDriverUiRecorder

Vladimir
  • 21
  • 2