Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access the supported patterns of the WindowsElement #1201

Open
darshanls opened this issue Jun 16, 2020 · 8 comments
Open

How to access the supported patterns of the WindowsElement #1201

darshanls opened this issue Jun 16, 2020 · 8 comments

Comments

@darshanls
Copy link

Hello,
I would like access the supported patterns for the WindowsElement like Scroll Item Patterns etc...
Because for some of the verification I want scroll the item into view without clicking on the element.

@liljohnak
Copy link

Took us forever to get a good version of scroll. Hope this helps get you started:

public void ScrollDownToElement(AppiumWebElement wpfList, string name)
{
  if(!localIsVerticallyScrollable()) return;
  while(localKeepScrolling())
  {
    var firstMatch = wpfList.FindElementsByXPath("*/*[@Name = '{name}']").FirstOrDefault(); //Check immediate children for elements with a name match
    if(name == null) OurMouseLibrary.MouseWheelScrollDown();
    else return;
  }
 
bool  localIsVerticallyScrollable()
{
  if(bool.TryParse(wpfList.GetAttribute("Scroll.VerticallyScrollable"), out bool isVerticallyScrollable)) return isVerticallyScrollable;
  return false;
}
bool localKeepScrolling()
{
  if(double.TryParse(wpfList.GetAttribute("Scroll.VerticalScrollPercent"), out double verticallyScrollPercent)) verticallyScrollPercent<100;
return false;
}
}

@darshanls
Copy link
Author

Thank a lot for the reply. Let me try this.

@darshanls
Copy link
Author

It's amazing solution I tried above suggestion, it almost works for my scenario.

Is there any way to call a method of pattern. For example ScrollItemPattern support a method ScrollIntoView(), now how to call ScrollIntoView() method from WindowElement. I think this single method can resolve many of my problem.

@liljohnak
Copy link

@darshanls not in C#. I saw a method in javascript() that would do this.

@liljohnak
Copy link

@darshanls The almost part of working for the rest of your cases can get a little complicated.
In my situation, I found two ways that worked well to know when I scrolled to the listItem enough to click it.

  1. listItem.GetAttribute("Offscreen") == false
  2. listItem.GetAttribute("BoundingRectangle") is contained within the ScrollViewer control

@liljohnak liljohnak mentioned this issue Dec 1, 2020
@anunay1
Copy link

anunay1 commented Dec 3, 2020

OurMouseLibrary.MouseWheelScrollDown();

@liljohnak : I am getting an error here, have you implemented this library? It will be good if you can share that also.

@huster-songtao
Copy link

ScrollDownToElement

#1538 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants