|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en-us"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8"> |
| 5 | + <title>Automotion by dzaiats</title> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 7 | + <link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen"> |
| 8 | + <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'> |
| 9 | + <link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen"> |
| 10 | + <link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen"> |
| 11 | + </head> |
| 12 | + <body> |
| 13 | + <section class="page-header"> |
| 14 | + <h1 class="project-name">Automotion</h1> |
| 15 | + <h2 class="project-tagline">Simple library for complex problems</h2> |
| 16 | + <a href="https://github.com/dzaiats/Automotion" class="btn">View on GitHub</a> |
| 17 | + <a href="https://github.com/dzaiats/Automotion/zipball/master" class="btn">Download .zip</a> |
| 18 | + <a href="https://github.com/dzaiats/Automotion/tarball/master" class="btn">Download .tar.gz</a> |
| 19 | + </section> |
| 20 | + |
| 21 | + <section class="main-content"> |
| 22 | + <h1> |
| 23 | +<a id="automotion" class="anchor" href="#automotion" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Automotion</h1> |
| 24 | + |
| 25 | +<p>This is JAVA library for the running of mobile, web or API automated tests.</p> |
| 26 | + |
| 27 | +<h3> |
| 28 | +<a id="steps-to-connect" class="anchor" href="#steps-to-connect" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Steps to connect</h3> |
| 29 | + |
| 30 | +<ul> |
| 31 | +<li> |
| 32 | +<p>Repo:</p> |
| 33 | + |
| 34 | +<ul> |
| 35 | +<li> |
| 36 | +<p>add dependecy:</p> |
| 37 | + |
| 38 | +<pre><code> <dependency> |
| 39 | + <groupId>net.itarray</groupId> |
| 40 | + <artifactId>automotion</artifactId> |
| 41 | + <version>1.4.0</version> |
| 42 | + </dependency> |
| 43 | +</code></pre> |
| 44 | +</li> |
| 45 | +</ul> |
| 46 | +</li> |
| 47 | +</ul> |
| 48 | + |
| 49 | +<h3> |
| 50 | +<a id="steps-of-adding-to-the-project" class="anchor" href="#steps-of-adding-to-the-project" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Steps of adding to the project</h3> |
| 51 | + |
| 52 | +<ul> |
| 53 | +<li> |
| 54 | +<p>Create instance of WebDriverFactory and call getDriver:</p> |
| 55 | + |
| 56 | +<pre><code> WebDriverFactory driverFactory = new WebDriverFactory(); |
| 57 | + WebDriver driver = driverFactory.getDriver(); |
| 58 | +</code></pre> |
| 59 | +</li> |
| 60 | +<li> |
| 61 | +<p>Extend Your page classes from BaseWebMobileElement class to have access to methods:</p> |
| 62 | + |
| 63 | +<pre><code> getWebElement(final By by) |
| 64 | + getWebElement(ExpectedCondition<WebElement> expectedCondition) |
| 65 | + |
| 66 | + getMobileElement(final By by, int timeOfWaiting) |
| 67 | + getMobileElement(final By by) |
| 68 | + |
| 69 | + getWebElements(final By by) |
| 70 | + getWebElements(ExpectedCondition<List<WebElement>> expectedCondition) |
| 71 | +</code></pre> |
| 72 | +</li> |
| 73 | +</ul> |
| 74 | + |
| 75 | +<h3> |
| 76 | +<a id="steps-of-using-during-test-run" class="anchor" href="#steps-of-using-during-test-run" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Steps of using during test run</h3> |
| 77 | + |
| 78 | +<h4> |
| 79 | +<a id="-do-not-forget-to-put-chrome-and-gecko-drivers-into-your-project-srctestresourcesdrivers-" class="anchor" href="#-do-not-forget-to-put-chrome-and-gecko-drivers-into-your-project-srctestresourcesdrivers-" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>! Do not forget to put Chrome and Gecko drivers into Your project src/test/resources/drivers !</h4> |
| 80 | + |
| 81 | +<ul> |
| 82 | +<li> |
| 83 | +<p>Specify env variables or system properties (example):</p> |
| 84 | + |
| 85 | +<ul> |
| 86 | +<li> |
| 87 | +<p>For Web local run: </p> |
| 88 | + |
| 89 | +<pre><code>IS_LOCAL=True |
| 90 | +BROWSER=Firefox|Chrome|IE|Safari |
| 91 | +</code></pre> |
| 92 | +</li> |
| 93 | +<li> |
| 94 | +<p>For Web remote run:</p> |
| 95 | + |
| 96 | +<pre><code>IS_REMOTE=True |
| 97 | +BROWSER=Firefox|Chrome|IE|Safari |
| 98 | +EXECUTOR=http://{host}:{port}/wd/hub |
| 99 | +(optional available with Chrome only) MOBILE_DEVICE_EMULATION=Google Nexus 5|Apple iPhone 6|Samsung Galaxy S5 |
| 100 | +</code></pre> |
| 101 | +</li> |
| 102 | +<li> |
| 103 | +<p>For Web Mobile run:</p> |
| 104 | + |
| 105 | +<pre><code>IS_MOBILE=True |
| 106 | +PLATFORM=Android|iOS |
| 107 | +BROWSER=Chrome|Safari |
| 108 | +EXECUTOR=http://{host}:{port}/wd/hub |
| 109 | +DEVICE=Device name |
| 110 | +</code></pre> |
| 111 | +</li> |
| 112 | +<li> |
| 113 | +<p>For Web Headless run (with PhantomJS without browser):</p> |
| 114 | + |
| 115 | +<pre><code>IS_HEADLESS=True |
| 116 | +BROWSER=Firefox|Chrome|IE|Safari |
| 117 | +PHANTOM_JS_PATH=C://phantomjs.exe |
| 118 | +</code></pre> |
| 119 | +</li> |
| 120 | +<li> |
| 121 | +<p>For Native Mobile run:</p> |
| 122 | + |
| 123 | +<pre><code>IS_MOBILE=True |
| 124 | +PLATFORM=Android|iOS |
| 125 | +APP={path_to_app} |
| 126 | +EXECUTOR=http://{host}:{port}/wd/hub |
| 127 | +DEVICE=Device name |
| 128 | +</code></pre> |
| 129 | +</li> |
| 130 | +<li> |
| 131 | +<p>For Windows UWP:</p> |
| 132 | + |
| 133 | +<pre><code>IS_MOBILE=True |
| 134 | +PLATFORM=Windows |
| 135 | +APP={path_to_app} |
| 136 | +EXECUTOR=http://{host}:{port}/wd/hub |
| 137 | +DEVICE=Device name or ID |
| 138 | +</code></pre> |
| 139 | +</li> |
| 140 | +</ul> |
| 141 | +</li> |
| 142 | +</ul> |
| 143 | + |
| 144 | +<h3> |
| 145 | +<a id="possibilities" class="anchor" href="#possibilities" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Possibilities</h3> |
| 146 | + |
| 147 | +<ul> |
| 148 | +<li> |
| 149 | +<p>Responsive UI Validator allows to validate UI on web or mobile page using lots of criterias. Also it allows tu build thr HTMl report after validation.</p> |
| 150 | + |
| 151 | +<pre><code> ResponsiveUIValidator uiValidator = new ResponsiveUIValidator(driver); |
| 152 | + |
| 153 | + |
| 154 | + boolean result = uiValidator.init() |
| 155 | + .findElement({rootEelement}, "Name of element") |
| 156 | + .sameOffsetLeftAs({element} "Panel 1") |
| 157 | + .sameOffsetLeftAs({element} "Button 1") |
| 158 | + .sameOffsetRightAs({element} "Button 2") |
| 159 | + .sameOffsetRightAs({element}, "Button 3) |
| 160 | + .withCssValue("border", "2px", "solid", "#FBDCDC") |
| 161 | + .withCssValue("border-radius", "4px") |
| 162 | + .withoutCssValue("color", "#FFFFFF") |
| 163 | + .sameSizeAs({list_elements},) |
| 164 | + .insideOf({element}, "Container") |
| 165 | + .notOverlapWith({element}, "Other element") |
| 166 | + .withTopElement({element}, 10, 15) |
| 167 | + .changeMetricsUnitsTo(ResponsiveUIValidator.Units.PERCENT) |
| 168 | + .widthBetween(50, 55) |
| 169 | + .heightBetween(90, 95) |
| 170 | + .drawMap() |
| 171 | + .validate(); |
| 172 | + |
| 173 | + |
| 174 | + uiValidator.generateReport(); |
| 175 | +</code></pre> |
| 176 | +</li> |
| 177 | +<li> |
| 178 | +<p>Verification that elements are aligned correctly on the web or mobile page</p> |
| 179 | + |
| 180 | +<ul> |
| 181 | +<li> |
| 182 | +<p>Elements horizontally are aligned correctly:</p> |
| 183 | + |
| 184 | +<pre><code>PageValidator.elementsAreAlignedHorizontally(List<WebElement> elements) - boolean |
| 185 | +</code></pre> |
| 186 | +</li> |
| 187 | +<li> |
| 188 | +<p>Elements vertically are aligned correctly:</p> |
| 189 | + |
| 190 | +<pre><code>PageValidator.elementsAreAlignedVertically(List<WebElement> elements) - boolean |
| 191 | +</code></pre> |
| 192 | +</li> |
| 193 | +<li> |
| 194 | +<p>Elements are aligned properly in general:</p> |
| 195 | + |
| 196 | +<pre><code>PageValidator.elementsAreAlignedProperly(List<WebElement> elements) - boolean |
| 197 | +</code></pre> |
| 198 | +</li> |
| 199 | +</ul> |
| 200 | +</li> |
| 201 | +<li> |
| 202 | +<p>Helpers that are useful in the very different situations:</p> |
| 203 | + |
| 204 | +<ul> |
| 205 | +<li> |
| 206 | +<p>Generate UUID with specified length:</p> |
| 207 | + |
| 208 | +<pre><code>Helper.getGeneratedStringWithLength(int length) - String |
| 209 | +</code></pre> |
| 210 | +</li> |
| 211 | +<li> |
| 212 | +<p>Create image file on fly:</p> |
| 213 | + |
| 214 | +<pre><code>Helper.createFile(String filename) - File. Will be saved in the folder "target/" that is been created after building |
| 215 | +</code></pre> |
| 216 | +</li> |
| 217 | +<li> |
| 218 | +<p>Parse JSON text:</p> |
| 219 | + |
| 220 | +<pre><code>Parser.getJSONValue(String textToParse, String key) - String |
| 221 | +</code></pre> |
| 222 | +</li> |
| 223 | +<li> |
| 224 | +<p>Parse XML text based on SAX algorithm:</p> |
| 225 | + |
| 226 | +<pre><code>Parser.getXMLValue(String xmlToParse, String xpath) - String |
| 227 | +Parser.getXMLValues(String xmlToParse, String xpath) - List<String> |
| 228 | +</code></pre> |
| 229 | +</li> |
| 230 | +<li> |
| 231 | +<p>Smart Text finder. Can find the string even in the broken text with corrupted characters:</p> |
| 232 | + |
| 233 | +<pre><code>TextFinder.textIsFound(String whatToFind, String whereToFind) - bool. Default derivation is 30% (0.3). It means that accuracy of searching will be 70% |
| 234 | +TextFinder.setDerivation(int newValue) - void. New value between 0 and 1. |
| 235 | +</code></pre> |
| 236 | +</li> |
| 237 | +<li> |
| 238 | +<p>Mail checker (IMAP). Possible to connect to any IMAP mail box (Gmail for example) and get the list of mails with access to the mail details.</p> |
| 239 | + |
| 240 | +<pre><code>MailService mailService = new MailService(); |
| 241 | +mailService |
| 242 | + .setFolder(MailService.MailFolder.INBOX) // (INBOX, SPAM, TRASH) |
| 243 | + .login(String IMAP_Server, int IMAP_Port, String email, String passwordToEmail); |
| 244 | + |
| 245 | + |
| 246 | +mailService.isLoggedIn()) - boolean |
| 247 | +mailService.getMessageCount() - integer |
| 248 | +mailService.getMessages() - Message[] |
| 249 | +mailService.getLastMessage() - Message - last message |
| 250 | +</code></pre> |
| 251 | +</li> |
| 252 | +<li> |
| 253 | +<p>Language validator. Algorithm based on semantic approach of languages validation on the web page. Allowed methods:</p> |
| 254 | + |
| 255 | +<pre><code>LanguageChecker.getRecognisedLanguage(String textToValidate) - Optional<LdLocale> |
| 256 | +Allowed method .get() to get access to the details. E.g LanguageChecker.getRecognisedLanguage(String textToValidate).get().getLanguage() will return "en" |
| 257 | + |
| 258 | +LanguageChecker.isCorrectLanguageOnThePage(WebDriver driver, String lang) - boolean. String lang is 2-chars abbreviature. E.g "en" or "es" |
| 259 | +</code></pre> |
| 260 | +</li> |
| 261 | +<li> |
| 262 | +<p>Web and mobile WebDriver Helpers that are useful in the very different situations:</p> |
| 263 | + |
| 264 | +<ul> |
| 265 | +<li> |
| 266 | +<p>All the methods are collected in both classes: MobileHelper and DriverHelper. The most useful pf them are:</p> |
| 267 | + |
| 268 | +<pre><code>DriverHelper.scrollDownWeb(WebDriver driver) |
| 269 | +DriverHelper.scrollUpWeb(WebDriver driver) |
| 270 | +DriverHelper.scrollDownMobile(AppiumDriver driver) |
| 271 | +DriverHelper.scrollUpMobile(AppiumDriver driver) |
| 272 | +DriverHelper.scrollDownMobile(AppiumDriver driver, int duration) - duration not less than 500ms |
| 273 | +DriverHelper.scrollUpMobile(AppiumDriver driver, int duration) - duration not less than 500ms |
| 274 | +DriverHelper.scrollDownMobileElement(AppiumDriver driver, MobileElement element) |
| 275 | +DriverHelper.scrollUpMobileElement(AppiumDriver driver, MobileElement element) |
| 276 | +DriverHelper.scrollDownMobileElement(AppiumDriver driver, MobileElement element, int duration) - duration not less than 500ms |
| 277 | +DriverHelper.scrollUpMobileElement(AppiumDriver driver, MobileElement element, int duration) - duration not less than 500ms |
| 278 | + |
| 279 | +DriverHelper.hideKeyboard(AppiumDriver driver) - super method that perform hiding of keyboard for Android and iOS |
| 280 | + |
| 281 | +DriverHelper.click(WebDriver driver, WebElement element) - Smart click that will try to click few times |
| 282 | + |
| 283 | +DriverHelper.clickByLocation(WebDriver driver, WebElement element, ClickPoint clickPoint) |
| 284 | +DriverHelper.clickByLocation(AppiumDriver driver, MobileElement element, ClickPoint clickPoint) - methods for clickin on the elements with specified point of click. |
| 285 | +Allowed ClickPoint are: ClickPoint.TOP_LEFT, ClickPoint.TOP_RIGHT, ClickPoint.BOTTOM_LEFT, ClickPoint.BOTTOM_RIGHT, ClickPoint.CENTER |
| 286 | + |
| 287 | +DriverHelper.clickJQuery(WebDriver driver, WebElement element) - click method that is performed by triggering JQuery native method |
| 288 | + |
| 289 | +DriverHelper.waitForPageIsReady(WebDriver driver) - wait for page is loaded and all the backgrounded process are finished |
| 290 | + |
| 291 | +MobileHelper.turnOnWifi() - turn on WiFI on Android Mobile device |
| 292 | +MobileHelper.turnOffWifi() - turn off WiFI on Android Mobile device |
| 293 | +MobileHelper.turnOnMobileData() - turn on Mobile data on Android Mobile device |
| 294 | +MobileHelper.turnOffMobileData() - turn off Mobile data on Android Mobile device |
| 295 | +MobileHelper.turnOnAirplaneMode() - turn on Airplane mode on Android Mobile device |
| 296 | +MobileHelper.turnOffAirplaneMode() - turn off Airplane mode on Android Mobile device |
| 297 | + |
| 298 | +MobileHelper.openAndroidNotifications(AppiumDriver driver) - open notification tray on Android devices |
| 299 | +</code></pre> |
| 300 | +</li> |
| 301 | +</ul> |
| 302 | +</li> |
| 303 | +</ul> |
| 304 | +</li> |
| 305 | +<li> |
| 306 | +<p>API calls. This part is very important because allows to perform different kind of HTTP(s) request with parameters.</p> |
| 307 | + |
| 308 | +<ul> |
| 309 | +<li> |
| 310 | +<p>Example of sending POST request:</p> |
| 311 | + |
| 312 | +<pre><code>new ConnectionFactory(String baseUrl).sendPost(Map map, String endpoint, String token, boolean withMediaFile) - return Map<Integer, String> where Integer is response code and String is response body |
| 313 | +Parameter map contains usual HTTP Pair-Values set of data in the representation of Java Map interface. |
| 314 | +String endpoint - is the ending of URL e.g "/api/v1/users". |
| 315 | +Parameter boolean withMediaFile is for advanced usage if You want to generate and upload some file |
| 316 | +Parameter token - is authorisation token if we want to perform request with auth. If not, just leave this parameter as empty string |
| 317 | +</code></pre> |
| 318 | +</li> |
| 319 | +<li> |
| 320 | +<p>Example of sending GET request:</p> |
| 321 | + |
| 322 | +<pre><code>new ConnectionFactory(String baseUrl).sendGet(String endpoint, String token) - return Map<Integer, String> where Integer is response code and String is response body |
| 323 | +String endpoint - is the ending of URL e.g "/api/v1/users?id=1" |
| 324 | +Parameter token - is authorisation token if we want to perform request with auth. If not, just leave this parameter as empty string |
| 325 | +</code></pre> |
| 326 | +</li> |
| 327 | +<li> |
| 328 | +<p>Example of sending PUT request:</p> |
| 329 | + |
| 330 | +<pre><code>new ConnectionFactory(String baseUrl).sendPut(Map map, String endpoint, String token) - return Map<Integer, String> where Integer is response code and String is response body |
| 331 | +Parameter map contains usual HTTP Pair-Values set of data in the representation of Java Map interface. |
| 332 | +String endpoint - is the ending of URL e.g "/api/v1/users". |
| 333 | +Parameter token - is authorisation token if we want to perform request with auth. If not, just leave this parameter as empty string |
| 334 | +</code></pre> |
| 335 | +</li> |
| 336 | +<li> |
| 337 | +<p>Example of sending DELETE request:</p> |
| 338 | + |
| 339 | +<pre><code>new ConnectionFactory(String baseUrl).sendDelete(String endpoint, String token) - return Map<Integer, String> where Integer is response code and String is response body |
| 340 | +String endpoint - is the ending of URL e.g "/api/v1/users?id=1" |
| 341 | +Parameter token - is authorisation token if we want to perform request with auth. If not, just leave this parameter as empty string |
| 342 | +</code></pre> |
| 343 | +</li> |
| 344 | +</ul> |
| 345 | +</li> |
| 346 | +</ul> |
| 347 | + |
| 348 | +<h3> |
| 349 | +<a id="contact" class="anchor" href="#contact" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Contact</h3> |
| 350 | + |
| 351 | +<p>Denys Zaiats |
| 352 | +<a href="mailto:denys.zaiats@gmail.com">denys.zaiats@gmail.com</a></p> |
| 353 | + |
| 354 | + <footer class="site-footer"> |
| 355 | + <span class="site-footer-owner"><a href="https://github.com/dzaiats/Automotion">Automotion</a> is maintained by <a href="https://github.com/dzaiats">dzaiats</a>.</span> |
| 356 | + |
| 357 | + <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span> |
| 358 | + </footer> |
| 359 | + |
| 360 | + </section> |
| 361 | + |
| 362 | + |
| 363 | + </body> |
| 364 | +</html> |
0 commit comments