public boolean setAtaque(String planeta, int naves) throws InterruptedException { consola("Intentando atacar a: " + planeta); String[] coor = planeta.split(":"); irAMenu("Flota"); int re = 0; try { (new WebDriverWait(driver, 30)) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.id("ship_203")).isEnabled(); } }); consola("Log: Ataque: Cargando flota"); // ((JavascriptExecutor) driver).executeScript("$(\".success\").remove();"); } catch (Exception e) { consola("Error: Ataque: No carga flota - " + e.getMessage()); return false; } WebElement txt_naves = driver.findElement(By.id("ship_203")); do { txt_naves.sendKeys(String.valueOf(naves)); Thread.sleep(500); } while ("".equals(driver.findElement(By.id("ship_203")).getAttribute("value"))); Thread.sleep(500); driver.findElement(By.id("continue")).click(); // galaxy driver.switchTo().defaultContent(); try { (new WebDriverWait(driver, 30)) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.id("galaxy")).isEnabled(); } }); consola("Log: Ataque: Cargando coordenadas"); // ((JavascriptExecutor) driver).executeScript("$(\".success\").remove();"); } catch (Exception e) { consola("Error: Ataque: No carga coordenadas - " + e.getMessage()); return false; } // driver.findElement(By.id("galaxy")).sendKeys(coor[0]); consola("Galaxia " + coor[0]); // do{ // driver.findElement(By.id("system")).sendKeys(coor[1]); ((JavascriptExecutor) driver).executeScript("$(\"#system\").val(\"" + coor[1] + "\")"); driver.findElement(By.id("position")).sendKeys(coor[2]); ((JavascriptExecutor) driver).executeScript("$(\"#position\").val(\"" + coor[2] + "\")"); Thread.sleep(500); // re++; consola("Fijando coordenadas a " + String.valueOf(coor[1]) + ":" + String.valueOf(coor[2])); // }while((!String.valueOf(coor[1]).equals(driver.findElement(By.id("system")).getAttribute("value")) && !String.valueOf(coor[2]).equals(driver.findElement(By.id("position")).getAttribute("value"))) || re < 3); driver.findElement(By.id("continue")).click(); // missionButton1 driver.switchTo().defaultContent(); try { (new WebDriverWait(driver, 30)) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.id("missionButton1")).isEnabled(); } }); consola("Log: Ataque: Cargando ataque"); // ((JavascriptExecutor) driver).executeScript("$(\".success\").remove();"); } catch (Exception e) { consola("Error: Ataque: No carga ataque - " + e.getMessage()); return false; } driver.findElement(By.id("missionButton1")).click(); // start Thread.sleep(200); driver.findElement(By.id("start")).click(); // Recargar try { (new WebDriverWait(driver, 30)) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(By.linkText("Recargar")).isEnabled(); } }); consola("Log: Ataque: Ataque Realizado"); // ((JavascriptExecutor) driver).executeScript("$(\".success\").remove();"); } catch (Exception e) { consola("Error: Ataque: Ataque Fallido - " + e.getMessage()); return false; } return true; }