nus-yam/ex-repair huggingface dataset:
Program: 20319
Project: 20319
Buggy source:
/** 
 * Finds the first of elements that match the Windows UIAutomation selector supplied.
 * @param selector a Windows UIAutomation selector
 * @return The first element that matches the given selector
 * @throws {@link org.openqa.selenium.WebDriverException} This method is notapplicable with browser/webview UI.
 * @throws {@link org.openqa.selenium.NoSuchElementException} when no one element is found
 */
default T findElementByWindowsUIAutomation(String selector){
  return findElement(MobileSelector.WINDOWS_UI_AUTOMATION.toString(),selector);
}

Fixed version (ground truth):
/** 
 * Finds the first of elements that match the Windows UIAutomation selector supplied.
 * @param selector a Windows UIAutomation selector
 * @return The first element that matches the given selector
 * @throws WebDriverException This method is not applicable with browser/webview UI.
 * @throws NoSuchElementException when no one element is found
 */
default T findElementByWindowsUIAutomation(String selector){
  return findElement(MobileSelector.WINDOWS_UI_AUTOMATION.toString(),selector);
}
Program: 20320
Project: 20320
Buggy source:
/** 
 * Finds a list of elements that match the Windows UIAutomation selector supplied.
 * @param selector a Windows UIAutomation selector
 * @return a list of elements that match the given selector
 * @throws {@link org.openqa.selenium.WebDriverException} This method is notapplicable with browser/webview UI.
 */
default List<T> findElementsByWindowsUIAutomation(String selector){
  return findElements(MobileSelector.WINDOWS_UI_AUTOMATION.toString(),selector);
}

Fixed version (ground truth):
/** 
 * Finds a list of elements that match the Windows UIAutomation selector supplied.
 * @param selector a Windows UIAutomation selector
 * @return a list of elements that match the given selector
 * @throws WebDriverException This method is not applicable with browser/webview UI.
 */
default List<T> findElementsByWindowsUIAutomation(String selector){
  return findElements(MobileSelector.WINDOWS_UI_AUTOMATION.toString(),selector);
}
Program: 20321
Project: 20321
Buggy source:
@BeforeClass public static void beforeClass() throws Exception {
  service=AppiumDriverLocalService.buildDefaultService();
  service.start();
  if (service == null || !service.isRunning()) {
    throw new RuntimeException("String_Node_Str");
  }
  File appDir=new File("String_Node_Str");
  File app=new File(appDir,"String_Node_Str");
  DesiredCapabilities capabilities=new DesiredCapabilities();
  capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"String_Node_Str");
  capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT,500000);
  capabilities.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());
  driver=new IOSDriver<>(service.getUrl(),capabilities);
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass() throws Exception {
  service=AppiumDriverLocalService.buildDefaultService();
  service.start();
  if (service == null || !service.isRunning()) {
    throw new AppiumServerHasNotBeenStartedLocallyException("String_Node_Str");
  }
  File appDir=new File("String_Node_Str");
  File app=new File(appDir,"String_Node_Str");
  DesiredCapabilities capabilities=new DesiredCapabilities();
  capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"String_Node_Str");
  capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT,500000);
  capabilities.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());
  driver=new IOSDriver<>(service.getUrl(),capabilities);
}
Program: 20322
Project: 20322
Buggy source:
@BeforeClass public static void beforeClass() throws Exception {
  service=AppiumDriverLocalService.buildDefaultService();
  service.start();
  if (service == null || !service.isRunning()) {
    throw new RuntimeException("String_Node_Str");
  }
  File appDir=new File("String_Node_Str");
  File app=new File(appDir,"String_Node_Str");
  DesiredCapabilities capabilities=new DesiredCapabilities();
  capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"String_Node_Str");
  capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT,500000);
  capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());
  driver=new IOSDriver<>(service.getUrl(),capabilities);
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass() throws Exception {
  service=AppiumDriverLocalService.buildDefaultService();
  service.start();
  if (service == null || !service.isRunning()) {
    throw new AppiumServerHasNotBeenStartedLocallyException("String_Node_Str");
  }
  File appDir=new File("String_Node_Str");
  File app=new File(appDir,"String_Node_Str");
  DesiredCapabilities capabilities=new DesiredCapabilities();
  capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"String_Node_Str");
  capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT,500000);
  capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"String_Node_Str");
  capabilities.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());
  driver=new IOSDriver<>(service.getUrl(),capabilities);
}
Program: 20323
Project: 20323
Buggy source:
@Test public void acceptAlertTest(){
  driver.findElement(MobileBy.IosUIAutomation(iOSAutomationText)).click();
  waiting.until(alertIsPresent());
  driver.switchTo().alert().accept();
}

Fixed version (ground truth):
@Test public void acceptAlertTest(){
  Supplier<Boolean> acceptAlert=() -> {
    driver.findElement(MobileBy.IosUIAutomation(iOSAutomationText)).click();
    waiting.until(alertIsPresent());
    driver.switchTo().alert().accept();
    return true;
  }
;
  assertTrue(acceptAlert.get());
}
Program: 20324
Project: 20324
Buggy source:
@Test public void dismissAlertTest(){
  driver.findElement(MobileBy.IosUIAutomation(iOSAutomationText)).click();
  waiting.until(alertIsPresent());
  driver.switchTo().alert().dismiss();
}

Fixed version (ground truth):
@Test public void dismissAlertTest(){
  Supplier<Boolean> dismissAlert=() -> {
    driver.findElement(MobileBy.IosUIAutomation(iOSAutomationText)).click();
    waiting.until(alertIsPresent());
    driver.switchTo().alert().dismiss();
    return true;
  }
;
  assertTrue(dismissAlert.get());
}
Program: 20325
Project: 20325
Buggy source:
@Test public void lockTest(){
  driver.lockDevice(20);
}

Fixed version (ground truth):
@Test public void lockTest(){
  Supplier<Boolean> lock=() -> {
    driver.lockDevice(20);
    return true;
  }
;
  assertTrue(lock.get());
}
Program: 20328
Project: 20328
Buggy source:
@Test public void checkThatTestWillNotBeFailedBecauseOfInvalidFindBy(){
  try {
    assertNotEquals(null,elementWhenAndroidLocatorIsNotDefinedAndThereIsInvalidFindBy.getAttribute("String_Node_Str"));
  }
 catch (  NoSuchElementException ignored) {
    return;
  }
  throw new RuntimeException(NoSuchElementException.class.getName() + "String_Node_Str");
}

Fixed version (ground truth):
@Test(expected=NoSuchElementException.class) public void checkThatTestWillNotBeFailedBecauseOfInvalidFindBy(){
  assertNotNull(elementWhenAndroidLocatorIsNotDefinedAndThereIsInvalidFindBy.getAttribute("String_Node_Str"));
}
Program: 20329
Project: 20329
Buggy source:
@Test public void checkThatElementWasNotFoundByIOSUIAutomator(){
  NoSuchElementException nsee=null;
  try {
    iosTextView.getAttribute("String_Node_Str");
  }
 catch (  Exception e) {
    nsee=(NoSuchElementException)e;
  }
  assertNotNull(nsee);
}

Fixed version (ground truth):
@Test(expected=NoSuchElementException.class) public void checkThatElementWasNotFoundByIOSUIAutomator(){
  assertNotNull(iosTextView.getAttribute("String_Node_Str"));
}
Program: 20330
Project: 20330
Buggy source:
@Test public void checkThatElementWasNotFoundByIOSUIAutomatorChain(){
  NoSuchElementException nsee=null;
  try {
    iosChainTextView.getAttribute("String_Node_Str");
  }
 catch (  Exception e) {
    nsee=(NoSuchElementException)e;
  }
  assertNotNull(nsee);
}

Fixed version (ground truth):
@Test(expected=NoSuchElementException.class) public void checkThatElementWasNotFoundByIOSUIAutomatorChain(){
  assertNotNull(iosChainTextView.getAttribute("String_Node_Str"));
}
Program: 20331
Project: 20331
Buggy source:
@Test public void chromeTest(){
  setUp();
  test();
}

Fixed version (ground truth):
@Test public void chromeTest(){
  WebDriver driver=new ChromeDriver();
  try {
    PageFactory.initElements(new AppiumFieldDecorator(driver,15,TimeUnit.SECONDS),this);
    driver.get(new File("String_Node_Str").toURI().toString());
    assertNotEquals(0,foundLinks.size());
    assertNotEquals(0,main.size());
    assertEquals(null,trap1);
    assertEquals(null,trap2);
  }
  finally {
    driver.quit();
  }
}
Program: 20332
Project: 20332
Buggy source:
@Test public void genericTestCse(){
  PageFactory.initElements(new AppiumFieldDecorator(new MockWebDriver()),new TempGenericPage<>());
}

Fixed version (ground truth):
@Test public void genericTestCse(){
  Supplier<Boolean> result=() -> {
    PageFactory.initElements(new AppiumFieldDecorator(new MockWebDriver()),new TempGenericPage<>());
    return true;
  }
;
  assertTrue(result.get());
}
Program: 20333
Project: 20333
Buggy source:
@Test public void checkThatTestWillNotBeFailedBecauseOfInvalidFindBy(){
  try {
    assertNotEquals(null,elementWhenAndroidLocatorIsNotDefinedAndThereIsInvalidFindBy.getAttribute("String_Node_Str"));
  }
 catch (  NoSuchElementException ignored) {
    return;
  }
  throw new RuntimeException(NoSuchElementException.class.getName() + "String_Node_Str");
}

Fixed version (ground truth):
@Test(expected=NoSuchElementException.class) public void checkThatTestWillNotBeFailedBecauseOfInvalidFindBy(){
  assertNotNull(elementWhenAndroidLocatorIsNotDefinedAndThereIsInvalidFindBy.getAttribute("String_Node_Str"));
}
Program: 20334
Project: 20334
Buggy source:
@Test public void checkThatElementWasNotFoundByAndroidUIAutomator(){
  NoSuchElementException nsee=null;
  try {
    androidUIAutomatorView.getText();
  }
 catch (  Exception e) {
    nsee=(NoSuchElementException)e;
  }
  assertNotNull(nsee);
}

Fixed version (ground truth):
@Test(expected=NoSuchElementException.class) public void checkThatElementWasNotFoundByAndroidUIAutomator(){
  assertNotNull(androidUIAutomatorView.getText());
}
Program: 20335
Project: 20335
Buggy source:
@Test public void checkThatElementWasNotFoundByAndroidUIAutomatorChain(){
  NoSuchElementException nsee=null;
  try {
    chainElementView.getText();
  }
 catch (  Exception e) {
    nsee=(NoSuchElementException)e;
  }
  assertNotNull(nsee);
}

Fixed version (ground truth):
@Test(expected=NoSuchElementException.class) public void checkThatElementWasNotFoundByAndroidUIAutomatorChain(){
  assertNotNull(chainElementView.getText());
}
Program: 20336
Project: 20336
Buggy source:
/** 
 * Method performs the searching for a single element by some selector defined by string and value of the given selector
 * @param by is a string selector
 * @param using is a value of the given selector
 * @return the first found element
 * @throws {@link org.openqa.selenium.WebDriverException} when current session doesn'tsupport the given selector or when value of the selector is not consistent.
 * @throws {@link org.openqa.selenium.NoSuchElementException} when no one element is found
 */
T findElement(String by,String using) throws WebDriverException ;

Fixed version (ground truth):
/** 
 * Method performs the searching for a single element by some selector defined by string and value of the given selector
 * @param by is a string selector
 * @param using is a value of the given selector
 * @return the first found element
 * @throws org.openqa.selenium.WebDriverException when current session doesn'tsupport the given selector or when value of the selector is not consistent.
 * @throws org.openqa.selenium.NoSuchElementException when no one element is found
 */
T findElement(String by,String using);
Program: 20337
Project: 20337
Buggy source:
/** 
 * Method performs the searching for a list of elements by some selector defined by string and value of the given selector
 * @param by is a string selector
 * @param using is a value of the given selector
 * @return a list of elements
 * @throws {@link org.openqa.selenium.WebDriverException} when current session doesn't supportthe given selector or when value of the selector is not consistent.
 */
List<T> findElements(String by,String using) throws WebDriverException ;

Fixed version (ground truth):
/** 
 * Method performs the searching for a list of elements by some selector defined by string and value of the given selector
 * @param by is a string selector
 * @param using is a value of the given selector
 * @return a list of elements
 * @throws org.openqa.selenium.WebDriverException when current session doesn't supportthe given selector or when value of the selector is not consistent.
 */
List<T> findElements(String by,String using);
Program: 20338
Project: 20338
Buggy source:
/** 
 * This method was moved to   {@link MobileCommand#hideKeyboardCommand(String,String)}
 */
@Deprecated public static Map.Entry<String,Map<String,?>> lockDeviceCommand(){
  return new AbstractMap.SimpleEntry<>(LOCK,prepareArguments("String_Node_Str",0));
}

Fixed version (ground truth):
/** 
 * This method was moved to   {@link MobileCommand#hideKeyboardCommand(String,String)}.
 */
@Deprecated public static Map.Entry<String,Map<String,?>> lockDeviceCommand(){
  return new AbstractMap.SimpleEntry<>(LOCK,prepareArguments("String_Node_Str",0));
}
Program: 20339
Project: 20339
Buggy source:
public JsonToMobileElementConverter(RemoteWebDriver driver,Map<String,Object> sessionParameters){
  super(driver);
  this.driver=driver;
  automation=String.valueOf(sessionParameters.get(AUTOMATION_NAME_PARAMETER)).toLowerCase();
  platform=String.valueOf(sessionParameters.get(PLATFORM_NAME_PARAMETER)).toLowerCase();
}

Fixed version (ground truth):
/** 
 * @param driver an instance of {@link org.openqa.selenium.remote.RemoteWebDriver} subclass
 * @param sessionParameters the map of current session parameters
 */
public JsonToMobileElementConverter(RemoteWebDriver driver,Map<String,Object> sessionParameters){
  super(driver);
  this.driver=driver;
  automation=String.valueOf(sessionParameters.get(AUTOMATION_NAME_PARAMETER)).toLowerCase();
  platform=String.valueOf(sessionParameters.get(PLATFORM_NAME_PARAMETER)).toLowerCase();
}
Program: 20340
Project: 20340
Buggy source:
/** 
 * This method was moved to   {@link MobileCommand#hideKeyboardCommand(String,String)}
 */
@Deprecated public static Map.Entry<String,Map<String,?>> hideKeyboardCommand(String strategy,String keyName){
  String[] parameters=new String[]{"String_Node_Str","String_Node_Str"};
  Object[] values=new Object[]{strategy,keyName};
  return new AbstractMap.SimpleEntry<>(HIDE_KEYBOARD,prepareArguments(parameters,values));
}

Fixed version (ground truth):
/** 
 * This method was moved to   {@link MobileCommand#hideKeyboardCommand(String,String)}.
 */
@Deprecated public static Map.Entry<String,Map<String,?>> hideKeyboardCommand(String strategy,String keyName){
  String[] parameters=new String[]{"String_Node_Str","String_Node_Str"};
  Object[] values=new Object[]{strategy,keyName};
  return new AbstractMap.SimpleEntry<>(HIDE_KEYBOARD,prepareArguments(parameters,values));
}
Program: 20341
Project: 20341
Buggy source:
/** 
 * This method was moved to   {@link MobileCommand#lockDeviceCommand(int)}
 */
@Deprecated public static Map.Entry<String,Map<String,?>> lockDeviceCommand(int seconds){
  return new AbstractMap.SimpleEntry<>(LOCK,prepareArguments("String_Node_Str",seconds));
}

Fixed version (ground truth):
/** 
 * This method was moved to   {@link MobileCommand#lockDeviceCommand(int)}.
 */
@Deprecated public static Map.Entry<String,Map<String,?>> lockDeviceCommand(int seconds){
  return new AbstractMap.SimpleEntry<>(LOCK,prepareArguments("String_Node_Str",seconds));
}
Program: 20342
Project: 20342
Buggy source:
@Deprecated public void pinch(int x,int y){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  int scrHeight=this.manage().window().getSize().getHeight();
  int yOffset=100;
  if (y - 100 < 0) {
    yOffset=y;
  }
 else   if (y + 100 > scrHeight) {
    yOffset=scrHeight - y;
  }
  TouchAction action0=new TouchAction(this).press(x,y - yOffset).moveTo(x,y).release();
  TouchAction action1=new TouchAction(this).press(x,y + yOffset).moveTo(x,y).release();
  multiTouch.add(action0).add(action1).perform();
}

Fixed version (ground truth):
/** 
 * This method is deprecated and it is going to be removed soon. Please use   {@link MultiTouchAction#pinch(int,int,int,int)} or{@link MultiTouchAction#pinch(int,int,int)}
 */
@Deprecated public void pinch(int x,int y){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  int scrHeight=this.manage().window().getSize().getHeight();
  int yOffset=100;
  if (y - 100 < 0) {
    yOffset=y;
  }
 else   if (y + 100 > scrHeight) {
    yOffset=scrHeight - y;
  }
  TouchAction action0=new TouchAction(this).press(x,y - yOffset).moveTo(x,y).release();
  TouchAction action1=new TouchAction(this).press(x,y + yOffset).moveTo(x,y).release();
  multiTouch.add(action0).add(action1).perform();
}
Program: 20343
Project: 20343
Buggy source:
@Deprecated public void tap(int fingers,int x,int y,int duration){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  for (int i=0; i < fingers; i++) {
    multiTouch.add(createTap(x,y,duration));
  }
  multiTouch.perform();
}

Fixed version (ground truth):
/** 
 * This method is deprecated and it is going to be removed soon. Please use   {@link MultiTouchAction#tap(int,int,int,int)}.
 */
@Deprecated public void tap(int fingers,int x,int y,int duration){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  for (int i=0; i < fingers; i++) {
    multiTouch.add(createTap(x,y,duration));
  }
  multiTouch.perform();
}
Program: 20344
Project: 20344
Buggy source:
@Deprecated public void zoom(int x,int y){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  int scrHeight=this.manage().window().getSize().getHeight();
  int yOffset=100;
  if (y - 100 < 0) {
    yOffset=y;
  }
 else   if (y + 100 > scrHeight) {
    yOffset=scrHeight - y;
  }
  TouchAction action0=new TouchAction(this).press(x,y).moveTo(0,-yOffset).release();
  TouchAction action1=new TouchAction(this).press(x,y).moveTo(0,yOffset).release();
  multiTouch.add(action0).add(action1).perform();
}

Fixed version (ground truth):
/** 
 * This method is deprecated and it is going to be removed soon. Please use   {@link MultiTouchAction#zoom(int,int,int,int)} or{@link MultiTouchAction#zoom(int,int,int)}.
 */
@Deprecated public void zoom(int x,int y){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  int scrHeight=this.manage().window().getSize().getHeight();
  int yOffset=100;
  if (y - 100 < 0) {
    yOffset=y;
  }
 else   if (y + 100 > scrHeight) {
    yOffset=scrHeight - y;
  }
  TouchAction action0=new TouchAction(this).press(x,y).moveTo(0,-yOffset).release();
  TouchAction action1=new TouchAction(this).press(x,y).moveTo(0,yOffset).release();
  multiTouch.add(action0).add(action1).perform();
}
Program: 20345
Project: 20345
Buggy source:
@Deprecated public void swipe(int startx,int starty,int endx,int endy,int duration){
}

Fixed version (ground truth):
/** 
 * This method is deprecated. It was moved to   {@link CreatesSwipeAction#swipe(int,int,int,int,int)}.
 */
@Deprecated public void swipe(int startx,int starty,int endx,int endy,int duration){
}
Program: 20346
Project: 20346
Buggy source:
/** 
 * Get the mjsonwp parameters for this Action.
 * @return A map of parameters for this touch action to pass as part of mjsonwp.
 */
protected ImmutableMap<String,ImmutableList<Object>> getParameters(){
  ImmutableList.Builder<Object> parameters=ImmutableList.builder();
  ImmutableList<ActionParameter> actionList=parameterBuilder.build();
  actionList.forEach(action -> {
    parameters.add(action.getParameterMap());
  }
);
  return ImmutableMap.of("String_Node_Str",parameters.build());
}

Fixed version (ground truth):
/** 
 * Get the mjsonwp parameters for this Action.
 * @return A map of parameters for this touch action to pass as part of mjsonwp.
 */
protected ImmutableMap<String,ImmutableList<Object>> getParameters(){
  ImmutableList.Builder<Object> parameters=ImmutableList.builder();
  ImmutableList<ActionParameter> actionList=parameterBuilder.build();
  actionList.forEach(action -> parameters.add(action.getParameterMap()));
  return ImmutableMap.of("String_Node_Str",parameters.build());
}
Program: 20347
Project: 20347
Buggy source:
@Deprecated public static Map.Entry<String,Map<String,?>> pressKeyCodeCommand(int key,Integer metastate){
  String[] parameters=new String[]{"String_Node_Str","String_Node_Str"};
  Object[] values=new Object[]{key,metastate};
  return new AbstractMap.SimpleEntry<>(PRESS_KEY_CODE,prepareArguments(parameters,values));
}

Fixed version (ground truth):
/** 
 * It is deprecated. Please use   {@link MobileCommand#pressKeyCodeCommand(int,Integer)} instead.
 */
@Deprecated public static Map.Entry<String,Map<String,?>> pressKeyCodeCommand(int key,Integer metastate){
  String[] parameters=new String[]{"String_Node_Str","String_Node_Str"};
  Object[] values=new Object[]{key,metastate};
  return new AbstractMap.SimpleEntry<>(PRESS_KEY_CODE,prepareArguments(parameters,values));
}
Program: 20348
Project: 20348
Buggy source:
@Deprecated public static Map.Entry<String,Map<String,?>> longPressKeyCodeCommand(int key,Integer metastate){
  String[] parameters=new String[]{"String_Node_Str","String_Node_Str"};
  Object[] values=new Object[]{key,metastate};
  return new AbstractMap.SimpleEntry<>(LONG_PRESS_KEY_CODE,prepareArguments(parameters,values));
}

Fixed version (ground truth):
/** 
 * It is deprecated. Please use   {@link MobileCommand#longPressKeyCodeCommand(int,Integer)} instead.
 */
@Deprecated public static Map.Entry<String,Map<String,?>> longPressKeyCodeCommand(int key,Integer metastate){
  String[] parameters=new String[]{"String_Node_Str","String_Node_Str"};
  Object[] values=new Object[]{key,metastate};
  return new AbstractMap.SimpleEntry<>(LONG_PRESS_KEY_CODE,prepareArguments(parameters,values));
}
Program: 20349
Project: 20349
Buggy source:
/** 
 * Executes JSONWP command and returns a response
 * @param driverCommand a JSONWP command
 * @return a result response
 */
Response execute(String driverCommand);

Fixed version (ground truth):
/** 
 * Executes JSONWP command and returns a response.
 * @param driverCommand a JSONWP command
 * @return a result response
 */
Response execute(String driverCommand);
Program: 20350
Project: 20350
Buggy source:
/** 
 * Creates a new mobile element locator. It instantiates   {@link WebElement}using @AndroidFindBy (-s), @iOSFindBy (-s) and @FindBy (-s) annotation sets
 * @param searchContext     The context to use when finding the element
 * @param by                a By locator strategy
 * @param shouldCache       is the flag that signalizes that elements whichare found once should be cached
 * @param duration          is a POJO which contains timeout parameters
 * @param originalWebDriver is an instance of WebDriver that is going to beused by a proxied element
 */
public AppiumElementLocator(SearchContext searchContext,By by,boolean shouldCache,TimeOutDuration duration,WebDriver originalWebDriver){
  this.searchContext=searchContext;
  this.shouldCache=shouldCache;
  this.timeOutDuration=duration;
  this.by=by;
  this.originalWebDriver=originalWebDriver;
  waitingFunction=new WaitingFunction(this.searchContext);
}

Fixed version (ground truth):
/** 
 * Creates a new mobile element locator. It instantiates   {@link WebElement}using @AndroidFindBy (-s), @iOSFindBy (-s) and @FindBy (-s) annotation sets
 * @param searchContext     The context to use when finding the element
 * @param by                a By locator strategy
 * @param shouldCache       is the flag that signalizes that elements whichare found once should be cached
 * @param duration          is a POJO which contains timeout parameters for the element to be searched
 * @param originalDuration  is a POJO which contains timeout parameters from page object which contains the element
 * @param originalWebDriver is an instance of WebDriver that is going to beused by a proxied element
 */
public AppiumElementLocator(SearchContext searchContext,By by,boolean shouldCache,TimeOutDuration duration,TimeOutDuration originalDuration,WebDriver originalWebDriver){
  this.searchContext=searchContext;
  this.shouldCache=shouldCache;
  this.timeOutDuration=duration;
  this.originalTimeOutDuration=originalDuration;
  this.by=by;
  this.originalWebDriver=originalWebDriver;
  waitingFunction=new WaitingFunction(this.searchContext);
}
Program: 20351
Project: 20351
Buggy source:
private List<WebElement> waitFor(){
  try {
    changeImplicitlyWaitTimeOut(0,TimeUnit.SECONDS);
    FluentWait<By> wait=new FluentWait<>(by);
    wait.withTimeout(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
    return wait.until(waitingFunction);
  }
 catch (  TimeoutException e) {
    return new ArrayList<>();
  }
 finally {
    changeImplicitlyWaitTimeOut(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
  }
}

Fixed version (ground truth):
private List<WebElement> waitFor(){
  try {
    changeImplicitlyWaitTimeOut(0,TimeUnit.SECONDS);
    FluentWait<By> wait=new FluentWait<>(by);
    wait.withTimeout(timeOutDuration.getTime(),timeOutDuration.getTimeUnit());
    return wait.until(waitingFunction);
  }
 catch (  TimeoutException e) {
    return new ArrayList<>();
  }
 finally {
    changeImplicitlyWaitTimeOut(originalTimeOutDuration.getTime(),originalTimeOutDuration.getTimeUnit());
  }
}
Program: 20352
Project: 20352
Buggy source:
@Override public CacheableLocator createLocator(AnnotatedElement annotatedElement){
  TimeOutDuration customDuration;
  if (annotatedElement.isAnnotationPresent(WithTimeout.class)) {
    WithTimeout withTimeout=annotatedElement.getAnnotation(WithTimeout.class);
    customDuration=new TimeOutDuration(withTimeout.time(),withTimeout.unit());
  }
 else {
    customDuration=timeOutDuration;
  }
  builder.setAnnotated(annotatedElement);
  By by=builder.buildBy();
  if (by != null) {
    return new AppiumElementLocator(searchContext,by,builder.isLookupCached(),customDuration,originalWebDriver);
  }
  return null;
}

Fixed version (ground truth):
@Override public CacheableLocator createLocator(AnnotatedElement annotatedElement){
  TimeOutDuration customDuration;
  if (annotatedElement.isAnnotationPresent(WithTimeout.class)) {
    WithTimeout withTimeout=annotatedElement.getAnnotation(WithTimeout.class);
    customDuration=new TimeOutDuration(withTimeout.time(),withTimeout.unit());
  }
 else {
    customDuration=timeOutDuration;
  }
  builder.setAnnotated(annotatedElement);
  By by=builder.buildBy();
  if (by != null) {
    return new AppiumElementLocator(searchContext,by,builder.isLookupCached(),customDuration,timeOutDuration,originalWebDriver);
  }
  return null;
}
Program: 20353
Project: 20353
Buggy source:
/** 
 * Set a setting for this test session It's probably better to use a convenience function, rather than use this function directly. Try finding the method for the specific setting you want to change.
 * @param setting AppiumSetting you wish to set.
 * @param value   value of the setting.
 */
protected void setSetting(AppiumSetting setting,Object value){
  setSettings(MobileCommand.prepareArguments(setting.toString(),value));
}

Fixed version (ground truth):
/** 
 * Set a setting for this test session It's probably better to use a convenience function, rather than use this function directly. Try finding the method for the specific setting you want to change.
 * @param setting AppiumSetting you wish to set.
 * @param value   value of the setting.
 */
protected void setSetting(AppiumSetting setting,Object value){
  setSettings(prepareArguments(setting.toString(),value));
}
Program: 20354
Project: 20354
Buggy source:
/** 
 * Set settings for this test session It's probably better to use a convenience function, rather than use this function directly. Try finding the method for the specific setting you want to change.
 * @param settings Map of setting keys and values.
 */
private void setSettings(ImmutableMap<?,?> settings){
  execute(SET_SETTINGS,MobileCommand.prepareArguments("String_Node_Str",settings));
}

Fixed version (ground truth):
/** 
 * Set settings for this test session It's probably better to use a convenience function, rather than use this function directly. Try finding the method for the specific setting you want to change.
 * @param settings Map of setting keys and values.
 */
private void setSettings(ImmutableMap<?,?> settings){
  execute(SET_SETTINGS,prepareArguments("String_Node_Str",settings));
}
Program: 20356
Project: 20356
Buggy source:
@After("String_Node_Str" + "String_Node_Str") public void afterNavigateTo(JoinPoint joinPoint) throws Throwable {
  try {
    String url=String.valueOf(joinPoint.getArgs()[0]);
    listener.afterNavigateTo(url,driver);
  }
 catch (  Throwable t) {
    throw getRootCause(t);
  }
}

Fixed version (ground truth):
@After("String_Node_Str" + "String_Node_Str" + "String_Node_Str") public void afterNavigateTo(JoinPoint joinPoint) throws Throwable {
  try {
    Object url=String.valueOf(joinPoint.getArgs()[0]);
    listener.afterNavigateTo(String.valueOf(url),driver);
  }
 catch (  Throwable t) {
    throw getRootCause(t);
  }
}
Program: 20357
Project: 20357
Buggy source:
@Before("String_Node_Str" + "String_Node_Str") public void beforeNavigateTo(JoinPoint joinPoint) throws Throwable {
  try {
    String url=String.valueOf(joinPoint.getArgs()[0]);
    listener.beforeNavigateTo(url,driver);
  }
 catch (  Throwable t) {
    throw getRootCause(t);
  }
}

Fixed version (ground truth):
@Before("String_Node_Str" + "String_Node_Str" + "String_Node_Str") public void beforeNavigateTo(JoinPoint joinPoint) throws Throwable {
  try {
    Object url=String.valueOf(joinPoint.getArgs()[0]);
    listener.beforeNavigateTo(String.valueOf(url),driver);
  }
 catch (  Throwable t) {
    throw getRootCause(t);
  }
}
Program: 20358
Project: 20358
Buggy source:
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Bean(name="String_Node_Str",destroyMethod="String_Node_Str") DefaultAspect getAspect(){
  DefaultAspect aspect=new DefaultAspect(context,driver);
  aspect.add(listeners);
  return aspect;
}

Fixed version (ground truth):
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Bean(name="String_Node_Str") DefaultAspect getAspect(){
  DefaultAspect aspect=new DefaultAspect(context,driver);
  aspect.add(listeners);
  return aspect;
}
Program: 20359
Project: 20359
Buggy source:
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Bean(name=COMPONENT_BEAN,destroyMethod="String_Node_Str") Object getComponent(Object component){
  return component;
}

Fixed version (ground truth):
@Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE) @Bean(name=COMPONENT_BEAN) Object getComponent(Object component){
  return component;
}
Program: 20360
Project: 20360
Buggy source:
@Override public void afterFindBy(By by,WebElement element,WebDriver driver){
  ((SearchingEventListener)driver).afterFindBy(by,element,driver);
}

Fixed version (ground truth):
@Override public void afterFindBy(By by,WebElement element,WebDriver driver){
  ((SearchingEventListener)dispatcher).afterFindBy(by,element,driver);
}
Program: 20361
Project: 20361
Buggy source:
@Override public void beforeFindBy(By by,WebElement element,WebDriver driver){
  ((SearchingEventListener)driver).beforeFindBy(by,element,driver);
}

Fixed version (ground truth):
@Override public void beforeFindBy(By by,WebElement element,WebDriver driver){
  ((SearchingEventListener)dispatcher).beforeFindBy(by,element,driver);
}
Program: 20362
Project: 20362
Buggy source:
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  for (  Listener l : listeners) {
    if (method.getDeclaringClass().isAssignableFrom(l.getClass())) {
      method.invoke(l,args);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  for (  Listener l : listeners) {
    if (method.getDeclaringClass().isAssignableFrom(l.getClass())) {
      method.invoke(l,args);
      return null;
    }
    Method webDriverEventListenerMethod=findElementInWebDriverEventListener(method);
    if (webDriverEventListenerMethod != null && WebDriverEventListener.class.isAssignableFrom(l.getClass())) {
      webDriverEventListenerMethod.invoke(l,args);
      return null;
    }
  }
  return null;
}
Program: 20364
Project: 20364
Buggy source:
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  for (  Listener l : listeners) {
    if (method.getDeclaringClass().isAssignableFrom(l.getClass())) {
      method.invoke(l,args);
    }
    Method webDriverEventListenerMethod=findElementInWebDriverEventListener(method);
    if (webDriverEventListenerMethod != null && WebDriverEventListener.class.isAssignableFrom(l.getClass())) {
      webDriverEventListenerMethod.invoke(l,args);
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  for (  Listener l : listeners) {
    boolean isInvoked=false;
    if (method.getDeclaringClass().isAssignableFrom(l.getClass())) {
      method.invoke(l,args);
      isInvoked=true;
    }
    if (isInvoked) {
      continue;
    }
    Method webDriverEventListenerMethod=findElementInWebDriverEventListener(method);
    if (webDriverEventListenerMethod != null && WebDriverEventListener.class.isAssignableFrom(l.getClass())) {
      webDriverEventListenerMethod.invoke(l,args);
    }
  }
  return null;
}
Program: 20365
Project: 20365
Buggy source:
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  for (  Listener l : listeners) {
    if (method.getDeclaringClass().isAssignableFrom(l.getClass())) {
      method.invoke(l,args);
      return null;
    }
    Method webDriverEventListenerMethod=findElementInWebDriverEventListener(method);
    if (webDriverEventListenerMethod != null && WebDriverEventListener.class.isAssignableFrom(l.getClass())) {
      webDriverEventListenerMethod.invoke(l,args);
      return null;
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  for (  Listener l : listeners) {
    if (method.getDeclaringClass().isAssignableFrom(l.getClass())) {
      method.invoke(l,args);
    }
    Method webDriverEventListenerMethod=findElementInWebDriverEventListener(method);
    if (webDriverEventListenerMethod != null && WebDriverEventListener.class.isAssignableFrom(l.getClass())) {
      webDriverEventListenerMethod.invoke(l,args);
    }
  }
  return null;
}
Program: 20366
Project: 20366
Buggy source:
/** 
 * Returns the interface for controlling IME engines to generate complex-script input.
 */
ImeHandler ime();

Fixed version (ground truth):
/** 
 * @return the interface for controlling IME engines to generate complex-script input.
 */
ImeHandler ime();
Program: 20367
Project: 20367
Buggy source:
/** 
 * Return an opaque handle to this window that uniquely identifies it within this driver instance. This can be used to switch to this window at a later date
 */
String getWindowHandle();

Fixed version (ground truth):
/** 
 * Return an opaque handle to this window that uniquely identifies it within this driver instance. This can be used to switch to this window at a later date
 * @return the current window handle
 */
String getWindowHandle();
Program: 20368
Project: 20368
Buggy source:
/** 
 * Returns the interface for managing driver timeouts.
 */
Timeouts timeouts();

Fixed version (ground truth):
/** 
 * @return the interface for managing driver timeouts.
 */
Timeouts timeouts();
Program: 20369
Project: 20369
Buggy source:
/** 
 * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored.
 * @param cookie
 */
void deleteCookie(Cookie cookie);

Fixed version (ground truth):
/** 
 * Delete a cookie from the browser's "cookie jar". The domain of the cookie will be ignored.
 * @param cookie nom nom nom
 */
void deleteCookie(Cookie cookie);
Program: 20370
Project: 20370
Buggy source:
/** 
 * Overloaded version of   {@link #to(String)} that makes it easy to pass in a URL.
 * @param url
 */
void to(URL url);

Fixed version (ground truth):
/** 
 * Overloaded version of   {@link #to(String)} that makes it easy to pass in a URL.
 * @param url URL
 */
void to(URL url);
Program: 20371
Project: 20371
Buggy source:
/** 
 * Specifies the amount of time the driver should wait when searching for an element if it is not immediately present. <p/> When searching for a single element, the driver should poll the page until the element has been found, or this timeout expires before throwing a   {@link NoSuchElementException}. When searching for multiple elements, the driver should poll the page until at least one element has been found or this timeout has expired. <p/> Increasing the implicit wait timeout should be used judiciously as it will have an adverse effect on test run time, especially when used with slower location strategies like XPath.
 * @param time The amount of time to wait.
 * @param unit The unit of measure for {@code time}.
 * @return A self reference.
 */
Timeouts implicitlyWait(long time,TimeUnit unit);

Fixed version (ground truth):
/** 
 * Specifies the amount of time the driver should wait when searching for an element if it is not immediately present. <p> When searching for a single element, the driver should poll the page until the element has been found, or this timeout expires before throwing a   {@link NoSuchElementException}. When searching for multiple elements, the driver should poll the page until at least one element has been found or this timeout has expired. <p> Increasing the implicit wait timeout should be used judiciously as it will have an adverse effect on test run time, especially when used with slower location strategies like XPath.
 * @param time The amount of time to wait.
 * @param unit The unit of measure for {@code time}.
 * @return A self reference.
 */
Timeouts implicitlyWait(long time,TimeUnit unit);
Program: 20372
Project: 20372
Buggy source:
/** 
 * Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that attribute is not present, in which case the value of the property with the same name is returned. If neither value is set, null is returned. The "style" attribute is converted as best can be to a text representation with a trailing semi-colon. The following are deemed to be "boolean" attributes, and will return either "true" or null: async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, spellcheck, truespeed, willvalidate Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected: <ul> <li>"class" <li>"readonly" </ul>
 * @param name The name of the attribute.
 * @return The attribute's current value or null if the value is not set.
 */
String getAttribute(String name);

Fixed version (ground truth):
/** 
 * Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that attribute is not present, in which case the value of the property with the same name is returned (for example for the "value" property of a textarea element). If neither value is set, null is returned. The "style" attribute is converted as best can be to a text representation with a trailing semi-colon. The following are deemed to be "boolean" attributes, and will return either "true" or null: async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, spellcheck, truespeed, willvalidate Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected: <ul> <li>"class" <li>"readonly" </ul>
 * @param name The name of the attribute.
 * @return The attribute/property's current value or null if the value is not set.
 */
String getAttribute(String name);
Program: 20373
Project: 20373
Buggy source:
/** 
 * Click this element. If this causes a new page to load, this method will attempt to block until  the page has loaded. At this point, you should discard all references to this element and any  further operations performed on this element will throw a StaleElementReferenceException unless you know the element and the page will still be present. If click() causes a new page to be  loaded via an event or is done by sending a native event then the method will *not* wait for it to be loaded and the caller should verify that a new page has been loaded. <p/> There are some preconditions for an element to be clicked.  The element must be visible and  it must have a height and width greater then 0.
 * @throws StaleElementReferenceException If the element no longer exists as initially defined
 */
void click();

Fixed version (ground truth):
/** 
 * Click this element. If this causes a new page to load, this method will attempt to block until  the page has loaded. At this point, you should discard all references to this element and any  further operations performed on this element will throw a StaleElementReferenceException unless you know the element and the page will still be present. If click() causes a new page to be  loaded via an event or is done by sending a native event then the method will *not* wait for it to be loaded and the caller should verify that a new page has been loaded. <p> There are some preconditions for an element to be clicked.  The element must be visible and  it must have a height and width greater then 0.
 * @throws StaleElementReferenceException If the element no longer exists as initially defined
 */
void click();
Program: 20374
Project: 20374
Buggy source:
/** 
 * Get the value of a given CSS property. Color values should be returned as rgba strings, so, for example if the "background-color" property is set as "green" in the HTML source, the returned value will be "rgba(0, 255, 0, 1)". Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, in accordance with the <a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration">DOM CSS2 specification</a> - you should directly access the longhand properties (e.g. background-color) to access the desired values.
 * @return The current, computed value of the property.
 */
String getCssValue(String propertyName);

Fixed version (ground truth):
/** 
 * Get the value of a given CSS property. Color values should be returned as rgba strings, so, for example if the "background-color" property is set as "green" in the HTML source, the returned value will be "rgba(0, 255, 0, 1)". Note that shorthand CSS properties (e.g. background, font, border, border-top, margin, margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned, in accordance with the <a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration">DOM CSS2 specification</a> - you should directly access the longhand properties (e.g. background-color) to access the desired values.
 * @param propertyName the css property name of the element
 * @return The current, computed value of the property.
 */
String getCssValue(String propertyName);
Program: 20375
Project: 20375
Buggy source:
/** 
 * Use this method to simulate typing into an element, which may set its value.
 */
void sendKeys(CharSequence... keysToSend);

Fixed version (ground truth):
/** 
 * Use this method to simulate typing into an element, which may set its value.
 * @param keysToSend character sequence to send to the element
 */
void sendKeys(CharSequence... keysToSend);
Program: 20376
Project: 20376
Buggy source:
/** 
 * Convenience method for "zooming in" on an element on the screen. "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other. NOTE: This convenience method slides touches away from the element, if this would happen to place one of them off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api instead of this method.
 * @param x x coordinate to start zoom on
 * @param y y coordinate to start zoom on
 */
public void zoom(int x,int y){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  int scrHeight=manage().window().getSize().getHeight();
  int yOffset=100;
  if (y - 100 < 0) {
    yOffset=y;
  }
 else   if (y + 100 > scrHeight) {
    yOffset=scrHeight - y;
  }
  TouchAction action0=new TouchAction(this).press(x,y).moveTo(x,y - yOffset).release();
  TouchAction action1=new TouchAction(this).press(x,y).moveTo(x,y + yOffset).release();
  multiTouch.add(action0).add(action1);
  multiTouch.perform();
}

Fixed version (ground truth):
/** 
 * Convenience method for "zooming in" on an element on the screen. "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other. NOTE: This convenience method slides touches away from the element, if this would happen to place one of them off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api instead of this method.
 * @param x x coordinate to start zoom on
 * @param y y coordinate to start zoom on
 */
public void zoom(int x,int y){
  MultiTouchAction multiTouch=new MultiTouchAction(this);
  int scrHeight=manage().window().getSize().getHeight();
  int yOffset=100;
  if (y - 100 < 0) {
    yOffset=y;
  }
 else   if (y + 100 > scrHeight) {
    yOffset=scrHeight - y;
  }
  TouchAction action0=new TouchAction(this).press(x,y).moveTo(0,-yOffset).release();
  TouchAction action1=new TouchAction(this).press(x,y).moveTo(0,yOffset).release();
  multiTouch.add(action0).add(action1);
  multiTouch.perform();
}
Program: 20377
Project: 20377
Buggy source:
/** 
 * Hides the keyboard if it is showing. On iOS, there are multiple strategies for hiding the keyboard. Defaults to the "tapOutside" strategy (taps outside the keyboard). Switch to using hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done") if this doesn't work.
 */
public void hideKeyboard();

Fixed version (ground truth):
/** 
 * Hides the keyboard if it is showing. On iOS, there are multiple strategies for hiding the keyboard. Defaults to the "tapOutside" strategy (taps outside the keyboard). Switch to using hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done") if this doesn't work.
 */
void hideKeyboard();
Program: 20378
Project: 20378
Buggy source:
/** 
 * Get all defined Strings from an app for the specified language
 * @param language strings language code
 * @return a string of all the localized strings defined in the app
 */
public String getAppStrings(String language);

Fixed version (ground truth):
/** 
 * Get all defined Strings from an app for the specified language
 * @param language strings language code
 * @return a string of all the localized strings defined in the app
 */
String getAppStrings(String language);