Click() on button or image
Click() on button or image
what will be the alternative method for click() on button or image since sometime object.click() missed the click , I tried w/delay, and object.performclick() but seems like both are not stable . Thank you in Advance.
Tipu
Re: Click() on button or image
Code: Select all
public void ImageLeftClick()
{
Ranorex.Imaging.FindOptions.Default.Similarity = 0.98;
Rectangle fullscreen = new Rectangle(0, 0, 1920, 1080);
Bitmap current = Ranorex.Imaging.CaptureDesktopImage(fullscreen);
Bitmap bmp = Ranorex.Imaging.Load("C:\\Users\\NAME\\Desktop\\image.bmp");
List<Ranorex.Imaging.Match> rtnList = Ranorex.Imaging.Find(current, bmp); //Captures Entire GuideDBS Screen to memory
int x = rtnList[0].Location.X + (rtnList[0].Size.Width/2); //Finds x center point
int y = rtnList[0].Location.Y + (rtnList[0].Size.Height/2); //Finds y center point
Ranorex.Mouse.Click(x, y);
int i = 0;
}
Re: Click() on button or image
This does not sound right. I've never seen Ranorex miss a click, unless the item to be clicked is offscreen and for some reason Ranorex was unable to scroll the screen.omayer wrote:what will be the alternative method for click() on button or image since sometime object.click() missed the click , I tried w/delay, and object.performclick() but seems like both are not stable . Thank you in Advance.
Is this a web AUT? Do you have the zoom set to something other than 100%?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Click() on button or image
Ciege, You are correct, click got missed when objects were offscreen and unable to scoll even though i have ensurevisible(), focus(). I do run my test on multiple screen which is connected to laptop .
Yes this is web AUT. Zoom set to 100%.
Yes this is web AUT. Zoom set to 100%.
Tipu
Re: Click() on button or image
In that case what I personally would do would be write my own Click method. Have this method take the element you want to click as a parameter. Have the method search for the element and check if it is visible or not. If it is visible, click it. If it is not visible, determine where it lives currently and have your own code scroll it into view. When the method is written, you can call it anytime you want to click something and be assured that it will work since you will be the one making sure it is visible.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Click() on button or image
Use the scrollbars... Use the keyboard...
How do people do it themselves? Mimic that with code...
How do people do it themselves? Mimic that with code...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...
Re: Click() on button or image
Playing with scrolling.
If you want to know how to do something try recording the action then have a look at the code.
If you want to know how to do something try recording the action then have a look at the code.
Code: Select all
public void Mouse_Up_Online_Search()
{
repo.Online_Search.Self.MoveTo("1254;506");
Mouse.ButtonUp(System.Windows.Forms.MouseButtons.Left);
}
public void Mouse_Down_Online_Search()
{
repo.Online_Search.Self.MoveTo("1251;232");
Mouse.ButtonDown(System.Windows.Forms.MouseButtons.Left);
}
public void Mouse_Wheel2()
{
Mouse.ScrollWheel(600);
}
public void Mouse_Wheel()
{
Mouse.ScrollWheel(-480);
}
Ian Fraser
Re: Click() on button or image
Thanks for this, and I wholeheartedly agree! The record/playback functionality can be of great use to quickly get an outline for your own code to do what needs to be done. It is a great way of learning how to code your own scripts. Just don't rely on it to do everything (like your error checking, etc)... Use it as another tool in your toolbox to get the job done...IanF wrote:If you want to know how to do something try recording the action then have a look at the code.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...