Appium cant find ID of 2/3 seekbar but all on the same page

Viewed 139

I've got 3 seekbar in my app on the same page:

page with 3 seekbar

I am trying to automate my app with Appium and C#, i am trying to move the seekbar by ID. The first one works like expected, but the other 2 cant be located by their id, error message:

System.InvalidOperationException: The coordinates provided to an interactions operation are invalid. (InvalidElementCoordinates)

My method:

public void moveSeekBar(string id, double valueToMove, AppiumDriver<IWebElement> driver)
    {
        IWebElement seek_bar = driver.FindElement(By.Id(id));
        //IWebElement seek_bar = driver.FindElement(By.XPath("//android.widget.SeekBar[@resource-id='" + id + "']"));
        int start = seek_bar.Location.X;
        int end = seek_bar.Size.Width;
        int y = seek_bar.Location.Y;

        TouchAction action = new TouchAction(driver);

        int moveTo = (int)(end * valueToMove);
        action.Press(start, y).MoveTo(moveTo, y).Release().Perform();
    }

And the maincode:

        string exam = "seekbarExam";
        string assessment = "seekbarAssessment";
        string homework = "seekbarHomework";

        noten.moveSeekBar(exam, 0, driver);
        Thread.Sleep(2000);
        noten.moveSeekBar(exam, 0.4, driver);
        Thread.Sleep(2000);            
        noten.moveSeekBar(assessment, 0, driver);
        Thread.Sleep(2000);
        noten.moveSeekBar(assessment, 0.3, driver);
        Thread.Sleep(2000);
        noten.moveSeekBar(homework, 0, driver);

I also tried to get the ID via XPath but obviously its not working because he seems to have a problem with the id.

ID of seekbar

I also used google but couldnt find someone with a similiar problem, maybe someone got a solution?

1 Answers

I fixed the error, Appium could'nt find the ID of the seekbars because somehow it did open the keyboard, and the keyboard blocked them. But to test seekbars you don't even make use of the keyboard, so I just let the keyboard disappear and it worked.

Maybe someone struggling with the same problem, so I just thought I would provide my solution.

Related