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

Developed .html files and tests for method element(final By locator). #22

Merged
merged 2 commits into from
Jul 26, 2017
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.wiley.autotest.framework.pages;

import com.wiley.autotest.selenium.context.AbstractPage;
import org.openqa.selenium.By;
import org.springframework.stereotype.Component;

/**
* Created by shekhavtsov on 20/07/2017.
*/
@Component
public class TestElementPage extends AbstractPage {

public TestElementPage checkFirstVisibleElement() {
element(By.cssSelector("li")).should().beDisplayed();
element(By.cssSelector("li")).should().haveText("element #1 (visible)");
return this;
}

public TestElementPage checkElementBecomeVisible() {
element(By.id("waitElement")).should().beDisplayed();
return this;
}

// The element changes coordinates. Each check validates element with different x, y.
public TestElementPage checkAnimationElement() {
element(By.id("myAnimation")).should().beDisplayed();
element(By.id("myAnimation")).should().beDisplayed();
element(By.id("myAnimation")).should().beDisplayed();
return this;
}

public TestElementPage checkElementInFrame() {
element(By.id("elementInFrame")).should().beDisplayed();
element(By.id("elementInFrame")).should().haveText("This page is displayed in an iframe #3");
return this;
}

public TestElementPage checkElementNotFound() {
element(By.id("elementNonexistent")).should().beDisplayed();
return this;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wiley.autotest.framework.tests.elements;

import com.wiley.autotest.framework.config.BaseTest;
import com.wiley.autotest.framework.pages.TestElementPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

/**
* Created by shekhavtsov on 20/07/2017.
*/
public class AnimationElement extends BaseTest {

@Autowired
private TestElementPage testElementPage;

@Test
public void test() {
openPage("mainTestElement.html");
testElementPage.checkAnimationElement();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.wiley.autotest.framework.tests.elements;

import com.wiley.autotest.framework.config.BaseTest;
import com.wiley.autotest.framework.pages.TestElementPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

/**
* Created by shekhavtsov on 20/07/2017.
*/
public class ElementInFrame extends BaseTest {

@Autowired
private TestElementPage testElementPage;

@Test
public void test() {
openPage("mainTestElement.html");
testElementPage.checkElementInFrame();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.wiley.autotest.framework.tests.elements;

import com.wiley.autotest.framework.config.BaseTest;
import com.wiley.autotest.framework.pages.TestElementPage;
import org.openqa.selenium.TimeoutException;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

/**
* Created by shekhavtsov on 21/07/2017.
*/
public class NonexistentElementhrowsException extends BaseTest {

@Autowired
private TestElementPage testElementPage;

@Test(expectedExceptions = TimeoutException.class)
public void test() {
openPage("mainTestElement.html");
testElementPage.checkElementNotFound();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.wiley.autotest.framework.tests.elements;

import com.wiley.autotest.framework.config.BaseTest;
import com.wiley.autotest.framework.pages.TestElementPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

/**
* Created by shekhavtsov on 20/07/2017.
*/
public class ReturnFirstVisibleElement extends BaseTest {

@Autowired
private TestElementPage testElementPage;

@Test
public void test() {
openPage("mainTestElement.html");
testElementPage.checkFirstVisibleElement();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.wiley.autotest.framework.tests.elements;

import com.wiley.autotest.framework.config.BaseTest;
import com.wiley.autotest.framework.pages.TestElementPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.Test;

/**
* Created by shekhavtsov on 20/07/2017.
*/
public class WaitElementBecomeVisible extends BaseTest {

@Autowired
private TestElementPage testElementPage;

@Test
public void test() {
openPage("mainTestElement.html");
testElementPage.checkElementBecomeVisible();
}

}
26 changes: 26 additions & 0 deletions src/test/resources/html/forTestElement/firstFrame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body style="background-color:#66f049 ">
<h2>This page is displayed in an iframe #1</h2>

<h1 id="waitElement">Element is visible after 6 sec!</h1>

<style>
#waitElement{
display: none;
}
</style>

<script>
setTimeout(becomeVisible, 6000);

function becomeVisible() {
document.getElementById("waitElement").style.display = "block";
}
</script>
</body>
</html>
53 changes: 53 additions & 0 deletions src/test/resources/html/forTestElement/secondFrame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body style="background-color:Khaki ">
<h2>This page is displayed in an iframe #2</h2>

<style>
#myContainer {
width: 200px;
height: 200px;
position: relative;
background: yellow;
}

#myAnimation {
width: 10px;
height: 10px;
position: absolute;
background-color: red;
}
</style>


<div id="myContainer">
<div id="myAnimation"></div>
</div>

<script>

myMove()

function myMove() {
var elem = document.getElementById("myAnimation");
var pos = 0;
var id = setInterval(frame, 5);

function frame() {
if (pos == 190) {
clearInterval(id);
} else {
pos++;
elem.style.top = pos + 'px';
elem.style.left = pos + 'px';
}
}
}
</script>

</body>

10 changes: 10 additions & 0 deletions src/test/resources/html/forTestElement/thirdFrame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body style="background-color:powderblue">
<h2 id="elementInFrame">This page is displayed in an iframe #3</h2>
</body>
</html>
29 changes: 29 additions & 0 deletions src/test/resources/html/framework/mainTestElement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tests for element</title>
</head>
<body>
<style>
li.hidden{
visibility: hidden;
}

li.invisible{
display: none;
}
</style>
<ul>
<li class="hidden">element #1 (hidden)</li>
<li class="invisible">element #2 (invisible)</li>
<li class="visible">element #1 (visible)</li>
<li class="visible">element #2 (visible)</li>
<li class="invisible">element #3 (hidden)</li>
</ul>
<iframe src="../forTestElement/firstFrame.html" height="300" width="400"></iframe>
<iframe src="../forTestElement/secondFrame.html" height="300" width="400"></iframe>
<iframe src="../forTestElement/thirdFrame.html" height="300" width="400"></iframe>

</body>
</html>