Program: 134438
Project: 134438
Buggy source:
/** 
 * This method is used by   {@link IDecomposable} method substitution mechanismIt takes into account situations when window/context should be found by some condition  
 * @param supportedDriver it is description of the supported {@link WebDriver} implementor
 * @param method Originally invoked method. It should be one of {@link IDecomposable} methods
 * @param args explicitly given arguments
 * @param annotatedElement is a {@link Field},   {@link Method} or {@link Class} which is supposed to be marked by  {@link Frame} and {@link RootElement}/  {@link RootAndroidElement}/  {@link RootIOSElement}
 * @return A new argument array
 * @throws Throwable
 */
static Object[] getRelevantArgs2(ESupportedDrivers supportedDriver,Method method,Object[] args,AnnotatedElement annotatedElement){
  IHowToGetHandle how=MethodReadingUtil.getDefinedParameter(method,IHowToGetHandle.class,args);
  if (how == null) {
    HowToGetMobileScreen howGetMobileScreen=null;
    HowToGetPage howToGetPage=getHowToGetHandleStrategy(DefaultPageIndex.class,ExpectedURL.class,ExpectedPageTitle.class,annotatedElement,HowToGetPage.class);
    if (supportedDriver.isForBrowser()) {
      how=howToGetPage;
    }
 else {
      howGetMobileScreen=getHowToGetHandleStrategy(DefaultContextIndex.class,ExpectedAndroidActivity.class,ExpectedContext.class,annotatedElement,HowToGetMobileScreen.class);
      howGetMobileScreen.defineHowToGetPageStrategy(howToGetPage);
      how=howGetMobileScreen;
    }
  }
  Integer index=MethodReadingUtil.getDefinedParameter(method,int.class,args);
  if (how != null && index != null) {
    how.setExpected(index.intValue());
  }
  Long timeOutLong=MethodReadingUtil.getDefinedParameter(method,long.class,args);
  if (timeOutLong == null)   timeOutLong=getTimeOut(annotatedElement);
  HowToGetByFrames howTo=MethodReadingUtil.getDefinedParameter(method,HowToGetByFrames.class,args);
  if (howTo == null)   howTo=getHowToGetByFramesStrategy(annotatedElement);
  By rootBy=MethodReadingUtil.getDefinedParameter(method,By.class,args);
  if (rootBy == null) {
    IRootElementReader rootElementReader=getRootElementReader(supportedDriver);
    rootBy=rootElementReader.readClassAndGetBy(annotatedElement,supportedDriver.getUsingWebDriverClass());
  }
  Object[] newArgs=new Object[]{extractTargetFromGetPart(method,args)};
  if (how != null) {
    newArgs=ArrayUtils.add(newArgs,how);
  }
 else   if (index != null) {
    newArgs=ArrayUtils.add(newArgs,index.intValue());
  }
  if (howTo != null) {
    newArgs=ArrayUtils.add(newArgs,howTo);
  }
  if (rootBy != null) {
    newArgs=ArrayUtils.add(newArgs,rootBy);
  }
  if (timeOutLong != null) {
    newArgs=ArrayUtils.add(newArgs,timeOutLong.longValue());
  }
  return newArgs;
}

Fixed version (ground truth):
/** 
 * This method is used by   {@link IDecomposable} method substitution mechanismIt takes into account situations when window/context should be found by some condition  
 * @param supportedDriver it is description of the supported {@link WebDriver} implementor
 * @param method Originally invoked method. It should be one of {@link IDecomposable} methods
 * @param args explicitly given arguments
 * @param annotatedElement is a {@link Field},   {@link Method} or {@link Class} which is supposed to be marked by  {@link Frame} and {@link RootElement}/  {@link RootAndroidElement}/  {@link RootIOSElement}
 * @return A new argument array
 * @throws Throwable
 */
static Object[] getRelevantArgs2(ESupportedDrivers supportedDriver,Method method,Object[] args,AnnotatedElement annotatedElement){
  IHowToGetHandle how=MethodReadingUtil.getDefinedParameter(method,IHowToGetHandle.class,args);
  if (how == null) {
    HowToGetMobileScreen howToGetMobileScreen=null;
    HowToGetPage howToGetPage=getHowToGetHandleStrategy(DefaultPageIndex.class,ExpectedURL.class,ExpectedPageTitle.class,annotatedElement,HowToGetPage.class);
    if (supportedDriver.isForBrowser()) {
      how=howToGetPage;
    }
 else {
      howToGetMobileScreen=getHowToGetHandleStrategy(DefaultContextIndex.class,ExpectedAndroidActivity.class,ExpectedContext.class,annotatedElement,HowToGetMobileScreen.class);
      if (howToGetMobileScreen != null)       howToGetMobileScreen.defineHowToGetPageStrategy(howToGetPage);
      how=howToGetMobileScreen;
    }
  }
  Integer index=MethodReadingUtil.getDefinedParameter(method,int.class,args);
  if (how != null && index != null) {
    how.setExpected(index.intValue());
  }
  Long timeOutLong=MethodReadingUtil.getDefinedParameter(method,long.class,args);
  if (timeOutLong == null)   timeOutLong=getTimeOut(annotatedElement);
  HowToGetByFrames howTo=MethodReadingUtil.getDefinedParameter(method,HowToGetByFrames.class,args);
  if (howTo == null)   howTo=getHowToGetByFramesStrategy(annotatedElement);
  By rootBy=MethodReadingUtil.getDefinedParameter(method,By.class,args);
  if (rootBy == null) {
    IRootElementReader rootElementReader=getRootElementReader(supportedDriver);
    rootBy=rootElementReader.readClassAndGetBy(annotatedElement,supportedDriver.getUsingWebDriverClass());
  }
  Object[] newArgs=new Object[]{extractTargetFromGetPart(method,args)};
  if (how != null) {
    newArgs=ArrayUtils.add(newArgs,how);
  }
 else   if (index != null) {
    newArgs=ArrayUtils.add(newArgs,index.intValue());
  }
  if (howTo != null) {
    newArgs=ArrayUtils.add(newArgs,howTo);
  }
  if (rootBy != null) {
    newArgs=ArrayUtils.add(newArgs,rootBy);
  }
  if (timeOutLong != null) {
    newArgs=ArrayUtils.add(newArgs,timeOutLong.longValue());
  }
  return newArgs;
}