Closed karunasaxena closed 6 years ago
http://lacontroller.maps.arcgis.com/apps/View/index.html?appid=cc0bc0590a18479ab89e0c102860d345
I want to click on each of the circle to capture its popup details. but I am not able to do perform click on circle using javascript.
I have tried to capture through selenium but it missed most of the circles clicks may be beacuse they are not in view area.
Below is the code snippet :-
public class MapDetails {
public static void main (String[] args) throws IOException, InterruptedException{ // DesiredCapabilities caps = new DesiredCapabilities(); System.setProperty("webdriver.chrome.driver","D:\selenium_chrome_2\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("http://lacontroller.maps.arcgis.com/apps/View/index.html?appid=cc0bc0590a18479ab89e0c102860d345"); JavascriptExecutor js = (JavascriptExecutor) driver ; WebDriverWait wait = new WebDriverWait(driver, 60); ArrayList sessionWindow = new ArrayList(); Thread.sleep(30000); ArrayList dots = new ArrayList(); driver.findElement(By.cssSelector(".pageNav.pageDown")).click(); WebElement chk1 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[0]"); chk1.click(); WebElement chk2 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[2]"); chk2.click(); WebElement chk3 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[3]"); chk3.click(); WebElement chk4 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[4]"); chk4.click(); js.executeScript("window.document.querySelector('#panelTop').setAttribute('class', '')"); js.executeScript("window.document.querySelector('#search').setAttribute('style', 'display:none;')");
//Blue //dots = (ArrayList<WebElement>) js.executeScript("return window.document.querySelectorAll('#csv_5814_0_layer [cx]')"); //Purple dots = (ArrayList<WebElement>) js.executeScript("return window.document.querySelectorAll('#csv_1923_0_layer [cx]')"); //Green //dots = (ArrayList<WebElement>) js.executeScript("return window.document.querySelectorAll('#csv_3865_0_layer [cx]')"); //driver.findElement(By.cssSelector(".esriSimpleSliderIncrementButton")).click(); //Thread.sleep(1000); //FileWriter fw = new FileWriter("D:\\selenium_chrome_2\\blue.csv", true); FileWriter fw = new FileWriter("D:\\selenium_chrome_2\\purpleTest\\purple.csv", true); //FileWriter fw = new FileWriter("D:\\selenium_chrome_2\\green.csv", true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out123 = new PrintWriter(bw); //FileWriter pendingLog = new FileWriter("D:\\selenium_chrome_2\\pendingBlue.csv", true); FileWriter pendingLog = new FileWriter("D:\\selenium_chrome_2\\purpleTest\\pendingPurple.csv", true); //FileWriter pendingLog = new FileWriter("D:\\selenium_chrome_2\\pendingGreen.csv", true); BufferedWriter bw1 = new BufferedWriter(pendingLog); PrintWriter pLog = new PrintWriter(bw1); //Blue //List<WebElement> circleElements = driver.findElements(By.cssSelector("#csv_5814_0_layer circle")); //Purple List<WebElement> circleElements = driver.findElements(By.cssSelector("#csv_1923_0_layer [cx]")); //Green //List<WebElement> circleElements = driver.findElements(By.cssSelector("#csv_3865_0_layer circle")); try{ for(int i=0 ; i <dots.size(); i++) { //WebElement circle = (WebElement) js.executeScript("return window.document.querySelectorAll('#csv_5814_0_layer circle')["+i+"]"); WebElement circle = circleElements.get(i); System.out.println("this iss the elemet ->"+circle); try{ Thread.sleep(1000); circle.click(); System.out.println("this is the true element ->"+circleElements.get(i)); }catch(Exception e){ System.out.println("this is the False element index ->"+circleElements.get(i).toString()); String failedCX = (String) js.executeScript("return document.querySelectorAll('#csv_1923_0_layer circle')["+i+"].getAttribute('cx')"); pLog.print("Failed index --->"+failedCX); continue; } ArrayList<WebElement> name = (ArrayList<WebElement>) js.executeScript("return window.document.querySelectorAll('.attrName')"); out123.print("\n"); System.out.println("Information of dot no -->"+i); for(int y = 0; y < name.size() ; y++) { String attrName = (String) js.executeScript("return window.document.querySelectorAll('.attrName')["+y+"].textContent"); String attrValue = (String) js.executeScript("return window.document.querySelectorAll('.attrValue')["+y+"].textContent"); System.out.println("Attribute Name =="+attrName+" && Attribute Value == "+attrValue); if(y != 0) out123.print(","); else out123.print(i+","); out123.print(attrName+","+attrValue); } Thread.sleep(1000);; try{ driver.findElement(By.cssSelector(".titleButton.close")).click(); }catch (Exception e){continue;} } }catch(Exception e){e.printStackTrace();} finally{ out123.close(); pLog.close(); }
}
@karunasaxena are you sure this is an issue with Pathagar?
http://lacontroller.maps.arcgis.com/apps/View/index.html?appid=cc0bc0590a18479ab89e0c102860d345
I want to click on each of the circle to capture its popup details. but I am not able to do perform click on circle using javascript.
I have tried to capture through selenium but it missed most of the circles clicks may be beacuse they are not in view area.
Below is the code snippet :-
public class MapDetails {
public static void main (String[] args) throws IOException, InterruptedException{ // DesiredCapabilities caps = new DesiredCapabilities(); System.setProperty("webdriver.chrome.driver","D:\selenium_chrome_2\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("http://lacontroller.maps.arcgis.com/apps/View/index.html?appid=cc0bc0590a18479ab89e0c102860d345"); JavascriptExecutor js = (JavascriptExecutor) driver ; WebDriverWait wait = new WebDriverWait(driver, 60); ArrayList sessionWindow = new ArrayList();
Thread.sleep(30000);
ArrayList dots = new ArrayList();
driver.findElement(By.cssSelector(".pageNav.pageDown")).click();
WebElement chk1 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[0]");
chk1.click();
WebElement chk2 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[2]");
chk2.click();
WebElement chk3 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[3]");
chk3.click();
WebElement chk4 = (WebElement) js.executeScript("return document.querySelectorAll('[type=\"checkbox\"]')[4]");
chk4.click();
js.executeScript("window.document.querySelector('#panelTop').setAttribute('class', '')");
js.executeScript("window.document.querySelector('#search').setAttribute('style', 'display:none;')");
}