← Back to team overview

sikuli-driver team mailing list archive

[Question #245679]: how to tell when vertical scroll bar is no longer present

 

New question #245679 on Sikuli:
https://answers.launchpad.net/sikuli/+question/245679

When the window is first displayed, the vertical scroll bar is present. I increase the height of the window until the vertical scroll bar is no longer present.  I am using an image of the up arrow on the vertical scroll bar so that I can break out of the loop when the vertical scrollbar is no longer present.   In the scenario I am testing, after increasing the window height once, the vertical scroll bar is not present, but the else condition in the loop is not executed as I was expecting.  The while loop continues to execute until  maxSteps is 0 and then exits the loop instead of breaking out of the loop when maxSteps is 2. I would appreciate some help with getting the code snippet below to work correctly. I have looked at the FAQs.  This line of code "if (null != reg.exists(arrowImage, 0)) "is not getting a null value even when the scroll bar is no longer present in the window.

code snippet:

Screen screen = new Screen();
			Region reg;
			reg = new Region(screen); //Screen is a region
			reg = App.focusedWindow(); // the region of the currently frontmost window
			int maxSteps = 3;
			int steps = 1;
			//increase window height until the vertical scroll bar is no longer present
			while (maxSteps > 0){
                               //check if the up arrow on the vertical scroll bar is present
				if (null != reg.exists(arrowImage, 0)){
			    	reg.click(increaseWindowHeightImage); //click on increase height image
			    	reg.wait(0.5);
			    	maxSteps -= steps;
			    	
			    }
			    else
			    {// arrow image not found; so break out of loop
			   	logger.info("vertical scroll bar not present");
			        break;
			    }
			}//end while

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.