Appium cannot find id 2/3, but all on one page

I have 3 search buttons in my application on one page:

page with 3 search buttons

I am trying to automate my application with Appium and C # , I am trying to move the search bar by ID. The first one works as expected, but the other 2 cannot be located by their identifier, error message:

System.InvalidOperationException: The coordinates provided by the interaction 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 main code:

  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 identifier through XPath, but obviously it does not work, because it seems to have an identifier problem.

search button id

I also used Google, but could not find someone with a similar problem, maybe someone got a solution?

+5
source share

Source: https://habr.com/ru/post/1269547/


All Articles