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

Amy's project #3

Open
wants to merge 2 commits into
base: NewAmy
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
26 changes: 26 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Selenium</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
5 changes: 5 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
11 changes: 7 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.symbio.test</groupId>
<artifactId>SeleniumPractice1</artifactId>
<artifactId>Selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>SeleniumPractice1</name>
<name>Selenium</name>
<url>http://maven.apache.org</url>

<properties>
Expand All @@ -18,13 +18,16 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>RELEASE</version>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<version>6.5.1</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>


13 changes: 13 additions & 0 deletions src/main/java/com/symbio/test/Selenium/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.symbio.test.Selenium;

/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
38 changes: 38 additions & 0 deletions src/test/java/com/symbio/test/Selenium/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.symbio.test.Selenium;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}

/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
53 changes: 53 additions & 0 deletions src/test/java/com/symbio/test/Selenium/Case1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.symbio.test.Selenium;

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.pagefactory.AjaxElementLocatorFactory;
import org.testng.annotations.Test;

public class Case1 {
@FindBy(css = ".ui3-city-change-inner.ui3-control-shadow>span")
private WebElement selectCityBtn;

@FindBy(css = "#selCityHotCityId>a[name='上海']")
private WebElement selectDetialCityBtn;

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

@FindBy(css = "#sub_start_input")
private WebElement start;

@FindBy(css = "#sub_end_input")
private WebElement end;

@FindBy(css = "#subSearchBtn")
private WebElement searchBtn;

@FindBy(css = "#btn_uf")
private WebElement expandResult;

WebDriver driver = new FirefoxDriver();
String URL = "http://map.baidu.com";
String FromStation = "虹桥1号航站楼";
String Destination = "世纪大道";

@Test
public void test1() {
// TODO Auto-generated method stub
PageFactory.initElements(new AjaxElementLocatorFactory(this.driver, 20), this);
driver.get(URL);
this.selectCityBtn.click();
this.selectDetialCityBtn.click();
this.subway.click();
this.start.sendKeys(FromStation);
this.end.sendKeys(Destination);
this.searchBtn.click();
this.expandResult.click();

}

}
72 changes: 72 additions & 0 deletions src/test/java/com/symbio/test/Selenium/Case2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.symbio.test.Selenium;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
import org.testng.annotations.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;

public class Case2 {
@FindBy(css = ".ui3-city-change-inner.ui3-control-shadow>span")
private WebElement selectCityBtn;

@FindBy(css = "#selCityHotCityId>a[name='北京']")
private WebElement selectDetialCityBtn;

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

@FindBy(css = ".tab-item.bus-tab")
private WebElement busBtn;

@FindBy(css = "#bus_start_input")
private WebElement start;

@FindBy(css = "#bus_end_input")
private WebElement end;

@FindBy(css = "#busSearchBtn")
private WebElement searchBtn;

@FindBy(css = "#select_type")
private WebElement trafficType;

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

@FindBy(css = "#type2")
private WebElement type2;

@FindBy(css = ".on>div>div>.bus_time")
private WebElement time;

WebDriver driver = new FirefoxDriver();
String URL = "http://map.baidu.com";
String FromStation = "上第五街";
String Destination = "故宫";

@Test
public void test2() {
// TODO Auto-generated method stub
PageFactory.initElements(new AjaxElementLocatorFactory(this.driver, 20), this);
driver.get(URL);
this.selectCityBtn.click();
this.selectDetialCityBtn.click();
this.route.click();
this.busBtn.click();
this.start.sendKeys(FromStation);
this.end.sendKeys(Destination);
this.searchBtn.click();
this.trafficType.click();
this.noSubway.click();
this.type2.click();
String useTime = this.time.getText();
System.out.println(useTime);

}

}
Binary file added target/classes/com/symbio/test/Selenium/App.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
84 changes: 84 additions & 0 deletions test-output/Default suite/Default test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<html>
<head>
<title>TestNG: Default test</title>
<link href="../testng.css" rel="stylesheet" type="text/css" />
<link href="../my-testng.css" rel="stylesheet" type="text/css" />

<style type="text/css">
.log { display: none;}
.stack-trace { display: none;}
</style>
<script type="text/javascript">
<!--
function flip(e) {
current = e.style.display;
if (current == 'block') {
e.style.display = 'none';
return 0;
}
else {
e.style.display = 'block';
return 1;
}
}

function toggleBox(szDivId, elem, msg1, msg2)
{
var res = -1; if (document.getElementById) {
res = flip(document.getElementById(szDivId));
}
else if (document.all) {
// this is the way old msie versions work
res = flip(document.all[szDivId]);
}
if(elem) {
if(res == 0) elem.innerHTML = msg1; else elem.innerHTML = msg2;
}

}

function toggleAllBoxes() {
if (document.getElementsByTagName) {
d = document.getElementsByTagName('div');
for (i = 0; i < d.length; i++) {
if (d[i].className == 'log') {
flip(d[i]);
}
}
}
}

// -->
</script>

</head>
<body>
<h2 align='center'>Default test</h2><table border='1' align="center">
<tr>
<td>Tests passed/Failed/Skipped:</td><td>1/0/0</td>
</tr><tr>
<td>Started on:</td><td>Mon Nov 23 16:03:15 CST 2015</td>
</tr>
<tr><td>Total time:</td><td>19 seconds (19414 ms)</td>
</tr><tr>
<td>Included groups:</td><td></td>
</tr><tr>
<td>Excluded groups:</td><td></td>
</tr>
</table><p/>
<small><i>(Hover the method name to see the test class name)</i></small><p/>
<table width='100%' border='1' class='invocation-passed'>
<tr><td colspan='4' align='center'><b>PASSED TESTS</b></td></tr>
<tr><td><b>Test method</b></td>
<td width="30%"><b>Exception</b></td>
<td width="10%"><b>Time (seconds)</b></td>
<td><b>Instance</b></td>
</tr>
<tr>
<td title='com.symbio.test.Selenium.Case2.test2()'><b>test2</b><br>Test class: com.symbio.test.Selenium.Case2</td>
<td></td>
<td>19</td>
<td>com.symbio.test.Selenium.Case2@4278fac9</td></tr>
</table><p>
</body>
</html>
5 changes: 5 additions & 0 deletions test-output/Default suite/Default test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by org.testng.reporters.JUnitXMLReporter -->
<testsuite hostname="zengnannan" name="Default test" tests="1" failures="0" timestamp="23 Nov 2015 08:03:35 GMT" time="19.414" errors="0">
<testcase name="test2" time="19.391" classname="com.symbio.test.Selenium.Case2"/>
</testsuite> <!-- Default test -->
13 changes: 13 additions & 0 deletions test-output/Default suite/testng-failed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Failed suite [Default suite]">
<test name="Default test(failed)">
<classes>
<class name="com.symbio.test.Selenium.Case2">
<methods>
<include name="test2"/>
</methods>
</class> <!-- com.symbio.test.Selenium.Case2 -->
</classes>
</test> <!-- Default test(failed) -->
</suite> <!-- Failed suite [Default suite] -->
Binary file added test-output/bullet_point.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test-output/collapseall.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test-output/emailable-report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>TestNG Report</title><style type="text/css">table {margin-bottom:10px;border-collapse:collapse;empty-cells:show}th,td {border:1px solid #009;padding:.25em .5em}th {vertical-align:bottom}td {vertical-align:top}table a {font-weight:bold}.stripe td {background-color: #E6EBF9}.num {text-align:right}.passedodd td {background-color: #3F3}.passedeven td {background-color: #0A0}.skippedodd td {background-color: #DDD}.skippedeven td {background-color: #CCC}.failedodd td,.attn {background-color: #F33}.failedeven td,.stripe .attn {background-color: #D00}.stacktrace {white-space:pre;font-family:monospace}.totop {font-size:85%;text-align:center;border-bottom:2px solid #000}</style></head><body><table><tr><th>Test</th><th># Passed</th><th># Skipped</th><th># Failed</th><th>Time (ms)</th><th>Included Groups</th><th>Excluded Groups</th></tr><tr><th colspan="7">Default suite</th></tr><tr><td><a href="#t0">Default test</a></td><td class="num">1</td><td class="num">0</td><td class="num">0</td><td class="num">19,414</td><td></td><td></td></tr></table><table><thead><tr><th>Class</th><th>Method</th><th>Start</th><th>Time (ms)</th></tr></thead><tbody><tr><th colspan="4">Default suite</th></tr></tbody><tbody id="t0"><tr><th colspan="4">Default test &#8212; passed</th></tr><tr class="passedeven"><td rowspan="1">com.symbio.test.Selenium.Case2</td><td><a href="#m0">test2</a></td><td rowspan="1">1448265795609</td><td rowspan="1">19391</td></tr></tbody></table><h2>Default test</h2><h3 id="m0">com.symbio.test.Selenium.Case2#test2</h3><table class="result"></table><p class="totop"><a href="#summary">back to summary</a></p></body></html>
Binary file added test-output/failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading