|
| 1 | +const Appium = require('../../lib/helper/Appium'); |
| 2 | +global.codeceptjs = require('../../lib'); |
| 3 | + |
| 4 | +let I; |
| 5 | +const site_url = 'http://davertmik.github.io'; |
| 6 | + |
| 7 | +describe('Appium Web', function () { |
| 8 | + this.retries(4); |
| 9 | + this.timeout(70000); |
| 10 | + |
| 11 | + before(() => { |
| 12 | + I = new Appium({ |
| 13 | + url: site_url, |
| 14 | + appiumV2: true, |
| 15 | + browser: 'chrome', |
| 16 | + restart: false, |
| 17 | + desiredCapabilities: { |
| 18 | + appiumVersion: '2.0.0', |
| 19 | + recordVideo: 'false', |
| 20 | + recordScreenshots: 'false', |
| 21 | + platformName: 'Android', |
| 22 | + platformVersion: '6.0', |
| 23 | + deviceName: 'Android Emulator', |
| 24 | + }, |
| 25 | + host: 'ondemand.saucelabs.com', |
| 26 | + port: 80, |
| 27 | + // port: 4723, |
| 28 | + // host: 'localhost', |
| 29 | + user: process.env.SAUCE_USERNAME, |
| 30 | + key: process.env.SAUCE_ACCESS_KEY, |
| 31 | + }); |
| 32 | + // I.isWeb = true; |
| 33 | + I._init(); |
| 34 | + I._beforeSuite(); |
| 35 | + }); |
| 36 | + |
| 37 | + after(() => I._finishTest()); |
| 38 | + |
| 39 | + beforeEach(() => { |
| 40 | + I.isWeb = true; |
| 41 | + return I._before(); |
| 42 | + }); |
| 43 | + |
| 44 | + afterEach(() => I._after()); |
| 45 | + |
| 46 | + describe('current url : #seeInCurrentUrl, #seeCurrentUrlEquals, ...', () => { |
| 47 | + it('should check for url fragment', async () => { |
| 48 | + await I.amOnPage('/angular-demo-app/#/info'); |
| 49 | + await I.seeInCurrentUrl('/info'); |
| 50 | + await I.dontSeeInCurrentUrl('/result'); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should check for equality', async () => { |
| 54 | + await I.amOnPage('/angular-demo-app/#/info'); |
| 55 | + await I.seeCurrentUrlEquals('/angular-demo-app/#/info'); |
| 56 | + await I.dontSeeCurrentUrlEquals('/angular-demo-app/#/result'); |
| 57 | + }); |
| 58 | + }); |
| 59 | + |
| 60 | + describe('see text : #see', () => { |
| 61 | + it('should check text on site', async () => { |
| 62 | + await I.amOnPage('/angular-demo-app/'); |
| 63 | + await I.see('Description'); |
| 64 | + await I.dontSee('Create Event Today'); |
| 65 | + }); |
| 66 | + |
| 67 | + it('should check text inside element', async () => { |
| 68 | + await I.amOnPage('/angular-demo-app/#/info'); |
| 69 | + await I.see('About', 'h1'); |
| 70 | + await I.see('Welcome to event app', { css: 'p.jumbotron' }); |
| 71 | + await I.see('Back to form', '//div/a'); |
| 72 | + }); |
| 73 | + }); |
| 74 | + |
| 75 | + describe('see element : #seeElement, #dontSeeElement', () => { |
| 76 | + it('should check visible elements on page', async () => { |
| 77 | + await I.amOnPage('/angular-demo-app/'); |
| 78 | + await I.seeElement('.btn.btn-primary'); |
| 79 | + await I.seeElement({ css: '.btn.btn-primary' }); |
| 80 | + await I.dontSeeElement({ css: '.btn.btn-secondary' }); |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + describe('#click', () => { |
| 85 | + it('should click by text', async () => { |
| 86 | + await I.amOnPage('/angular-demo-app/'); |
| 87 | + await I.dontSeeInCurrentUrl('/info'); |
| 88 | + await I.click('Get more info!'); |
| 89 | + await I.seeInCurrentUrl('/info'); |
| 90 | + }); |
| 91 | + |
| 92 | + it('should click by css', async () => { |
| 93 | + await I.amOnPage('/angular-demo-app/'); |
| 94 | + await I.click('.btn-primary'); |
| 95 | + await I.wait(2); |
| 96 | + await I.seeInCurrentUrl('/result'); |
| 97 | + }); |
| 98 | + |
| 99 | + it('should click by non-optimal css', async () => { |
| 100 | + await I.amOnPage('/angular-demo-app/'); |
| 101 | + await I.click('form a.btn'); |
| 102 | + await I.wait(2); |
| 103 | + await I.seeInCurrentUrl('/result'); |
| 104 | + }); |
| 105 | + |
| 106 | + it('should click by xpath', async () => { |
| 107 | + await I.amOnPage('/angular-demo-app/'); |
| 108 | + await I.click('//a[contains(., "more info")]'); |
| 109 | + await I.seeInCurrentUrl('/info'); |
| 110 | + }); |
| 111 | + |
| 112 | + it('should click on context', async () => { |
| 113 | + await I.amOnPage('/angular-demo-app/'); |
| 114 | + await I.click('.btn-primary', 'form'); |
| 115 | + await I.wait(2); |
| 116 | + await I.seeInCurrentUrl('/result'); |
| 117 | + }); |
| 118 | + |
| 119 | + it('should click link with inner span', async () => { |
| 120 | + await I.amOnPage('/angular-demo-app/#/result'); |
| 121 | + await I.click('Go to info'); |
| 122 | + await I.seeInCurrentUrl('/info'); |
| 123 | + }); |
| 124 | + |
| 125 | + it('should click buttons as links', async () => { |
| 126 | + await I.amOnPage('/angular-demo-app/'); |
| 127 | + await I.click('Options'); |
| 128 | + await I.seeInCurrentUrl('/options'); |
| 129 | + }); |
| 130 | + }); |
| 131 | + |
| 132 | + describe('#grabTextFrom, #grabValueFrom, #grabAttributeFrom', () => { |
| 133 | + it('should grab text from page', async () => { |
| 134 | + await I.amOnPage('/angular-demo-app/#/info'); |
| 135 | + const val = await I.grabTextFrom('p.jumbotron'); |
| 136 | + val.should.be.equal('Welcome to event app'); |
| 137 | + }); |
| 138 | + |
| 139 | + it('should grab value from field', async () => { |
| 140 | + await I.amOnPage('/angular-demo-app/#/options'); |
| 141 | + const val = await I.grabValueFrom('#ssh'); |
| 142 | + val.should.be.equal('PUBLIC-SSH-KEY'); |
| 143 | + }); |
| 144 | + |
| 145 | + it('should grab attribute from element', async () => { |
| 146 | + await I.amOnPage('/angular-demo-app/#/info'); |
| 147 | + const val = await I.grabAttributeFrom('a.btn', 'ng-href'); |
| 148 | + val.should.be.equal('#/'); |
| 149 | + }); |
| 150 | + }); |
| 151 | + |
| 152 | + describe('#within', () => { |
| 153 | + afterEach(() => I._withinEnd()); |
| 154 | + |
| 155 | + it('should work using within operator', async () => { |
| 156 | + await I.amOnPage('/angular-demo-app/#/options'); |
| 157 | + await I.see('Choose if you ok with terms'); |
| 158 | + await I._withinBegin({ css: 'div.results' }); |
| 159 | + await I.see('SSH Public Key: PUBLIC-SSH-KEY'); |
| 160 | + await I.dontSee('Options'); |
| 161 | + }); |
| 162 | + }); |
| 163 | +}); |
0 commit comments