Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

may commit #7

Open
wants to merge 2 commits into
base: may
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baidu.test</groupId>
<artifactId>MapPractise</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>MapPractise</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>



</project>
129 changes: 129 additions & 0 deletions src/main/java/com/baidu/test/SearchWhichWayToSelect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package com.baidu.test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

public class SearchWhichWayToSelect {

private WebDriver dr = new FirefoxDriver();
// private WebDriverWait wait = new WebDriverWait(dr,80000);

@FindBy(css = ".ui3-city-change-inner.ui3-control-shadow")
private WebElement city;

@FindBy(css = "a[name='上海']")
private WebElement shangHaiCityItem;

@FindBy(css = "a[name='北京']")
private WebElement beiJingCityItem;

@FindBy(css = ".subway-item")
private WebElement subWay;

@FindBy(id = "route_menu")
private WebElement routeMenu;

@FindBy(css = ".route_menu")
private WebElement bus;

@FindBy(id = "bus_start_input")
private WebElement bus_start;

@FindBy(id = "bus_end_input")
private WebElement bus_end;

@FindBy(id = "sub_start_input")
private WebElement startFrom;

@FindBy(id = "sub_end_input")
private WebElement endFrom;

@FindBy(id = "busSearchBtn")
private WebElement busSearchButton;

@FindBy(id = "subSearchBtn")
private WebElement searchButton;

@FindBy(id = "btn_uf")
private WebElement detailButton;

@FindBy(css = "#routes_detail")
private WebElement detail;

@FindBy(css = "#select_type")
private WebElement trafficType;// 这里不能用css = .traffic_type 定位,用这个时,点击事件不起作用

@FindBy(css = ".nosubway")
private WebElement noSubWay;

@FindBy(css = "#scheme_0 .bus_time")
private WebElement FirstItemBusTime;

public SearchWhichWayToSelect() {
PageFactory.initElements(dr, this);
}
@Test
public void test() throws InterruptedException {
dr.get("http://map.baidu.com/");
Thread.sleep(20000);
this.city.click();
Thread.sleep(3000);
this.shangHaiCityItem.click();
Thread.sleep(3000);
this.subWay.click();
Thread.sleep(3000);
this.startFrom.sendKeys("上海大学");
Thread.sleep(3000);
this.endFrom.sendKeys("陆家嘴");
Thread.sleep(3000);
this.searchButton.click();
Thread.sleep(3000);
this.detailButton.click();
Thread.sleep(8000);
System.out.println(this.detail.getText());
Thread.sleep(9000);


}

@Test
public void test2() throws InterruptedException {
dr.get("http://map.baidu.com/");
Thread.sleep(20000);
this.city.click();
Thread.sleep(3000);
this.beiJingCityItem.click();
Thread.sleep(10000);
this.routeMenu.click();
Thread.sleep(3000);
this.bus_start.sendKeys("上地五街");
Thread.sleep(3000);
this.bus_end.sendKeys("故宫");
Thread.sleep(3000);
this.busSearchButton.click();
Thread.sleep(30000);
this.trafficType.click();

Thread.sleep(8000);
this.noSubWay.click();
Thread.sleep(9000);
System.out.println(this.FirstItemBusTime.getText());

}
@AfterClass
public void afterClass(){
dr.close();
}

// @Test
// public void test3() throws InterruptedException{
// this.test2();
// }

}