| Line 110... |
Line 110... |
| 110 |
boolean captchaNotBroken = true;
|
110 |
boolean captchaNotBroken = true;
|
| 111 |
do {
|
111 |
do {
|
| 112 |
String fileName = "/tmp/oppo-simple-i-" + counter + " " + System.currentTimeMillis() + ".png";
|
112 |
String fileName = "/tmp/oppo-simple-i-" + counter + " " + System.currentTimeMillis() + ".png";
|
| 113 |
try {
|
113 |
try {
|
| 114 |
System.out.println("Starting Do");
|
114 |
System.out.println("Starting Do");
|
| 115 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_wrapper_1")));
|
115 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| 116 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_slider_1")));
|
116 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
| 117 |
slideButton = driver.findElement(By.id("dx_captcha_basic_slider_1"));
|
117 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
| 118 |
//System.out.println("Slide button - " + slideButton);
|
118 |
//System.out.println("Slide button - " + slideButton);
|
| 119 |
System.out.println("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
119 |
System.out.println("Margin Left before- " + slideButton.getCssValue("margin-left"));
|
| 120 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
120 |
actionProvider.moveToElement(slideButton).clickAndHold()
|
| 121 |
.moveByOffset(1, 0)//.pause(2000)
|
121 |
.moveByOffset(1, 0)//.pause(2000)
|
| 122 |
.perform();
|
122 |
.perform();
|
| Line 177... |
Line 177... |
| 177 |
System.out.println("Failed = " + counter + " ----------" + e.getMessage());
|
177 |
System.out.println("Failed = " + counter + " ----------" + e.getMessage());
|
| 178 |
}
|
178 |
}
|
| 179 |
}
|
179 |
}
|
| 180 |
}
|
180 |
}
|
| 181 |
System.out.println("After circles conditions");
|
181 |
System.out.println("After circles conditions");
|
| 182 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_wrapper_1")));
|
182 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_wrapper_')]")));
|
| 183 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.id("dx_captcha_basic_slider_1")));
|
183 |
wait10Sec.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]")));
|
| 184 |
slideButton = driver.findElement(By.id("dx_captcha_basic_slider_1"));
|
184 |
slideButton = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_slider_')]"));
|
| 185 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
185 |
actionProvider.moveToElement(slideButton).doubleClick().perform();
|
| 186 |
System.out.println("Ending Do" + counter++);
|
186 |
System.out.println("Ending Do" + counter++);
|
| 187 |
|
187 |
|
| 188 |
} while (captchaNotBroken && counter <= 20);
|
188 |
} while (captchaNotBroken && counter <= 20);
|
| 189 |
System.out.println("Counter reached upto 20");
|
189 |
System.out.println("Counter reached upto 20");
|
| Line 237... |
Line 237... |
| 237 |
|
237 |
|
| 238 |
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
238 |
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
| 239 |
BufferedImage fullImg = ImageIO.read(screenshot);
|
239 |
BufferedImage fullImg = ImageIO.read(screenshot);
|
| 240 |
|
240 |
|
| 241 |
// Get the location of element on the page
|
241 |
// Get the location of element on the page
|
| 242 |
WebElement imageElement = driver.findElement(By.id("dx_captcha_basic_bg_1"));
|
242 |
WebElement imageElement = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_bg_')]"));
|
| 243 |
Point point = imageElement.getLocation();
|
243 |
Point point = imageElement.getLocation();
|
| 244 |
|
244 |
|
| 245 |
// Get width and height of the element
|
245 |
// Get width and height of the element
|
| 246 |
int eleWidth = imageElement.getSize().getWidth();
|
246 |
int eleWidth = imageElement.getSize().getWidth();
|
| 247 |
int eleHeight = imageElement.getSize().getHeight();
|
247 |
int eleHeight = imageElement.getSize().getHeight();
|
| Line 268... |
Line 268... |
| 268 |
private double[] getMatCircles2(WebDriver driver, String fileName) throws Exception {
|
268 |
private double[] getMatCircles2(WebDriver driver, String fileName) throws Exception {
|
| 269 |
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
269 |
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
|
| 270 |
BufferedImage fullImg = ImageIO.read(screenshot);
|
270 |
BufferedImage fullImg = ImageIO.read(screenshot);
|
| 271 |
|
271 |
|
| 272 |
// Get the location of element on the page
|
272 |
// Get the location of element on the page
|
| 273 |
WebElement imageElement = driver.findElement(By.id("dx_captcha_basic_bg_1"));
|
273 |
WebElement imageElement = driver.findElement(By.xpath("//*[starts-with(@id, 'dx_captcha_basic_bg_')]"));
|
| 274 |
Point point = imageElement.getLocation();
|
274 |
Point point = imageElement.getLocation();
|
| 275 |
|
275 |
|
| 276 |
// Get width and height of the element
|
276 |
// Get width and height of the element
|
| 277 |
int eleWidth = imageElement.getSize().getWidth();
|
277 |
int eleWidth = imageElement.getSize().getWidth();
|
| 278 |
int eleHeight = imageElement.getSize().getHeight();
|
278 |
int eleHeight = imageElement.getSize().getHeight();
|