码迷,mamicode.com
首页 > Web开发 > 详细

selenium WebDriver 操作高德地图

时间:2015-05-12 22:22:27      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

            String URL="http://www.amap.com/";
            WebDriver driver = new FirefoxDriver(profile);
            driver.get(URL);
            driver.manage().window().maximize();
            driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
            WebElement chooseCityElement=driver.findElement(By.xpath("//div/span[@class=‘icon_expand cursor ml5‘]"));
            chooseCityElement.click();
            WebElement city_iframe=driver.findElement(By.xpath("//iframe[@id=‘city_iframe‘]"));
            driver.switchTo().frame(city_iframe);
            WebElement BJ=driver.findElement(By.xpath("//div/a[text()=‘北京‘]"));
            BJ.click();
            driver.switchTo().defaultContent();
            WebElement inputBoxElement=driver.findElement(By.xpath("//input[@id=‘keywordTxt‘]"));
            WebElement searchButton=driver.findElement(By.xpath("//input[starts-with(@class,‘magnifier_button‘)]"));
            inputBoxElement.clear();
            inputBoxElement.sendKeys("天安门");
            searchButton.submit();
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
            WebElement tiAnMenElement=driver.findElement(By.xpath("//div[@title=‘天安门‘]"));
            tiAnMenElement.click();
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
            
            WebElement comeToHereElement=driver.findElement(By.xpath("//div[@class=‘route‘]//li[text()=‘到这里去‘]"));
            comeToHereElement.click();
            
            WebElement setStartLocationElement =driver.findElement(By.xpath("//div/input[@class=‘route-input srh-ipt‘]"));
            setStartLocationElement.sendKeys("火车站");
            WebElement routeByBus=driver.findElement(By.xpath("//div[@id=‘rout-by-bus‘]"));
            routeByBus.click();
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
            WebElement startFrom=driver.findElement(By.xpath("//div[@class=‘start_end_item_title‘ and contains(text(),‘北京站‘)]"));
            Actions actions= new Actions(driver);
            actions.moveToElement(startFrom).click(driver.findElement(By.xpath("//a[contains(text(),‘设为起点‘) and @data-name=‘北京站‘]"))).perform();
            driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
            
            
            driver.findElement(By.xpath("//div[@class=‘amap-zoom-plus‘]")).click();
            

 

selenium WebDriver 操作高德地图

标签:

原文地址:http://www.cnblogs.com/tobecrazy/p/4498577.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!