String url= "http://www.amap.com/"; Webdriver Driver=Newfirefoxdriver (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 () = ' Beijing ']")); 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 (Tiananmen); Searchbutton.submit (); Driver.manage (). Timeouts (). Pageloadtimeout (30, Timeunit.seconds); Webelement tianmenelement=driver.findelement (By.xpath ("//div[@title = ' Tiananmen Square ']")); Tianmenelement.click (); Driver.manage (). Timeouts (). Pageloadtimeout (30, Timeunit.seconds); Webelement cometohereelement=driver.findelement (By.xpath ("//div[@class = ' route ']//li[text () = ' go here ']")); Cometohereelement.click (); Webelement setstartlocationelement=driver.findelement (By.xpath ("//div/input[@class = ' route-input srh-ipt ']")); Setstartlocationelement.sendkeys (Train station); 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 (), ' Beijing Station ')]")); Actions Actions=NewActions (driver); Actions.movetoelement (Startfrom). Click (Driver.findelement (By.xpath ("//a[contains (Text (), ' Set as the starting point ') and @data-name= ' Beijing Station ']")) . Perform (); Driver.manage (). Timeouts (). Pageloadtimeout (30, Timeunit.seconds); Driver.findelement (By.xpath ("//div[@class = ' amap-zoom-plus ']") . Click ();
Selenium Webdriver Operation German map