diff --git a/DemoApp/src/test/java/com/demo/tests/BaseTest.java b/DemoApp/src/test/java/com/demo/tests/BaseTest.java index 1d0ee16..490110b 100644 --- a/DemoApp/src/test/java/com/demo/tests/BaseTest.java +++ b/DemoApp/src/test/java/com/demo/tests/BaseTest.java @@ -5,8 +5,10 @@ import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; @@ -32,6 +34,7 @@ public WebDriver launchBrowser() { capabilities.setPlatform(Platform.WINDOWS); capabilities.setCapability("marionette", true); driver = new FirefoxDriver(capabilities); + driver.manage().deleteAllCookies(); driver.get(Url); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); @@ -68,7 +71,7 @@ public void elementPresence(By by, long seconds) { } // this method will quite the browser instance after executing the script. - //@AfterTest + @AfterTest public void tearDown() { getDriver().quit(); } @@ -102,5 +105,17 @@ public String getCurrentDate(){ } + public void scrollIntoElement(By id){ + + WebElement element = driver.findElement(id); + JavascriptExecutor js = (JavascriptExecutor) getDriver(); + js.executeScript("arguments[0].scrollIntoView(true);",element); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/DemoApp/src/test/java/com/demo/tests/DemoTest.java b/DemoApp/src/test/java/com/demo/tests/DemoTest.java index f72b86e..52418db 100644 --- a/DemoApp/src/test/java/com/demo/tests/DemoTest.java +++ b/DemoApp/src/test/java/com/demo/tests/DemoTest.java @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.Collections; - -import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -14,45 +12,62 @@ public class DemoTest extends BaseTest{ HomePage homePage; - + + //launching the browser with emirates url @BeforeClass public void setUp(){ launchBrowser(); homePage = new HomePage(getDriver()); } + @Test - public void test(){ + public void test() throws InterruptedException{ + // waiting for the emirates home page should display and entering the departure airport elementPresence(homePage.departureAirportTxt,40); safeType(homePage.departureAirportTxt,"DXB"); safeClick(homePage.departureAirportList); - + // Entering the arrival airport elementPresence(homePage.arrivalAirportTxt,40); safeType(homePage.arrivalAirportTxt,"LHR"); safeClick(homePage.arrivalAirportList); + // clicking on the data picker text box for selecting the particular travel date + safeClick(homePage.datePicker); - //safeClick(homePage.continueBtn); + // clicking on the particular travel date from the calender and its parameterized enter any date which one needs to travel + scrollIntoElement(homePage.selectTravelDate("13 May 18")); + safeClick(homePage.selectTravelDate("13 May 18")); + Thread.sleep(1000); - safeClick(homePage.datePicker); + //clicking on the particular retunr travel date from the calender and its parameterized enter any date which one needs to travel + scrollIntoElement(homePage.selectReturnDate("20 May 18")); + safeClick(homePage.selectReturnDate("20 May 18")); + Thread.sleep(1000); - getActions().moveToElement(getDriver().findElement(homePage.selectTravelDate)).click().build().perform(); + // clicking on into the Search button + scrollIntoElement(homePage.searchFlightsBtn); + safeClick(homePage.searchFlightsBtn); - getActions().moveToElement(getDriver().findElement(homePage.selectReturnDate)).click().build().perform(); - - getActions().moveToElement(getDriver().findElement(homePage.searchFlightsBtn)).click().build().perform(); + // waiting for the flights searcg results should display + elementPresence(homePage.searchResultList,40); + scrollIntoElement(homePage.searchResultList); - ArrayList price = (ArrayList) getDriver().findElements(By.xpath("//div[@class='ts-fbr-option__price-detail']/strong[@class='ts-fbr-option__price']")); + // getting all the price into the Array list + ArrayList price = (ArrayList) getDriver().findElements(homePage.searchResultList); + System.out.println("the web elements are ::"+price); + + // getting the price from the search result page and adding into the array list ArrayList priceLst = new ArrayList(); for(int i=0;i

Default test

- + - + - + @@ -67,8 +67,8 @@

Default test

Tests passed/Failed/Skipped:0/1/0Tests passed/Failed/Skipped:1/0/0
Started on:Sun May 06 16:36:06 IST 2018Started on:Sun May 06 18:54:06 IST 2018
Total time:67 seconds (67293 ms)
Total time:46 seconds (46792 ms)
Included groups:

(Hover the method name to see the test class name)

- - +
FAILED TESTS
+ @@ -76,95 +76,8 @@

Default test

PASSED TESTS
Test method Exception Time (seconds)
- - + +
test
Test class: com.demo.tests.DemoTest
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.name: search-flight-date-picker--depart (tried for 30 second(s) with 500 milliseconds interval)
-	at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:81)
-	at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:271)
-	at com.demo.tests.BaseTest.safeClick(BaseTest.java:85)
-	at com.demo.tests.DemoTest.test(DemoTest.java:34)
-	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
-	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
-	at java.lang.reflect.Method.invoke(Unknown Source)
-	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
-	at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
-	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
-	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
-	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
-	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
-	at org.testng.TestRunner.privateRun(TestRunner.java:648)
-	at org.testng.TestRunner.run(TestRunner.java:505)
-	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
-	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
-	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
-	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
-	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
-	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
-	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
-	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
-	at org.testng.TestNG.runSuites(TestNG.java:1049)
-	at org.testng.TestNG.run(TestNG.java:1017)
-	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
-	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
-	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
-Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.name: search-flight-date-picker--depart
-For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
-Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
-System info: host: 'DELL', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121'
-Driver info: driver.version: unknown
-	at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$0(ExpectedConditions.java:896)
-	at java.util.Optional.orElseThrow(Unknown Source)
-	at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
-	at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:44)
-	at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:206)
-	at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:202)
-	at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:248)
-	... 27 more
-
Click to show all stack frames -
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.name: search-flight-date-picker--depart (tried for 30 second(s) with 500 milliseconds interval)
-	at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:81)
-	at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:271)
-	at com.demo.tests.BaseTest.safeClick(BaseTest.java:85)
-	at com.demo.tests.DemoTest.test(DemoTest.java:34)
-	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
-	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
-	at java.lang.reflect.Method.invoke(Unknown Source)
-	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
-	at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
-	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
-	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
-	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
-	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
-	at org.testng.TestRunner.privateRun(TestRunner.java:648)
-	at org.testng.TestRunner.run(TestRunner.java:505)
-	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
-	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
-	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
-	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
-	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
-	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
-	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
-	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
-	at org.testng.TestNG.runSuites(TestNG.java:1049)
-	at org.testng.TestNG.run(TestNG.java:1017)
-	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
-	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
-	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
-Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.name: search-flight-date-picker--depart
-For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
-Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
-System info: host: 'DELL', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121'
-Driver info: driver.version: unknown
-	at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$0(ExpectedConditions.java:896)
-	at java.util.Optional.orElseThrow(Unknown Source)
-	at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
-	at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:44)
-	at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:206)
-	at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:202)
-	at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:248)
-	... 27 more
-
4424 com.demo.tests.DemoTest@66d1af89

diff --git a/DemoApp/test-output/Default suite/Default test.xml b/DemoApp/test-output/Default suite/Default test.xml index bc46ea2..c1654cf 100644 --- a/DemoApp/test-output/Default suite/Default test.xml +++ b/DemoApp/test-output/Default suite/Default test.xml @@ -1,52 +1,5 @@ - - - - - - + + diff --git a/DemoApp/test-output/emailable-report.html b/DemoApp/test-output/emailable-report.html index a47ffd2..269921d 100644 --- a/DemoApp/test-output/emailable-report.html +++ b/DemoApp/test-output/emailable-report.html @@ -9,53 +9,10 @@ - +
Test# Passed# Skipped# FailedTime (ms)Included GroupsExcluded Groups
Default suite
Default test00167,293
Default test10046,792
- +
ClassMethodStartTime (ms)
Default suite
Default test — failed
com.demo.tests.DemoTesttest152560478900944541
ClassMethodStartTime (ms)
Default suite
Default test — passed
com.demo.tests.DemoTesttest152561306911824588
-

Default test

com.demo.tests.DemoTest#test

Exception
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.name: search-flight-date-picker--depart (tried for 30 second(s) with 500 milliseconds interval) - at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:81) - at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:271) - at com.demo.tests.BaseTest.safeClick(BaseTest.java:85) - at com.demo.tests.DemoTest.test(DemoTest.java:34) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) - at java.lang.reflect.Method.invoke(Unknown Source) - at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124) - at org.testng.internal.Invoker.invokeMethod(Invoker.java:583) - at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719) - at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989) - at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) - at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) - at org.testng.TestRunner.privateRun(TestRunner.java:648) - at org.testng.TestRunner.run(TestRunner.java:505) - at org.testng.SuiteRunner.runTest(SuiteRunner.java:455) - at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450) - at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415) - at org.testng.SuiteRunner.run(SuiteRunner.java:364) - at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) - at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84) - at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208) - at org.testng.TestNG.runSuitesLocally(TestNG.java:1137) - at org.testng.TestNG.runSuites(TestNG.java:1049) - at org.testng.TestNG.run(TestNG.java:1017) - at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132) - at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230) - at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76) -Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.name: search-flight-date-picker--depart -For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html -Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z' -System info: host: 'DELL', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121' -Driver info: driver.version: unknown - at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$0(ExpectedConditions.java:896) - at java.util.Optional.orElseThrow(Unknown Source) - at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895) - at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:44) - at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:206) - at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:202) - at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:248) - ... 27 more -

back to summary

+

Default test

com.demo.tests.DemoTest#test

back to summary

diff --git a/DemoApp/test-output/index.html b/DemoApp/test-output/index.html index 08f7450..cda323a 100644 --- a/DemoApp/test-output/index.html +++ b/DemoApp/test-output/index.html @@ -24,7 +24,7 @@
Test results
- 1 suite, 1 failed test + 1 suite