How to use getElementAttribute method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

app_test.js

Source:app_test.js Github

copy

Full Screen

...6 test.assertTitle('Content - Test Blog', 'Ghost admin has incorrect title');7 test.assertUrlMatch(/ghost\/\d+\/$/, 'Landed on the correct URL');8 });9 casper.then(function testNavItems() {10 var logoHref = this.getElementAttribute('.gh-nav-footer-sitelink', 'href'),11 contentHref = this.getElementAttribute('.gh-nav-main-content', 'href'),12 editorHref = this.getElementAttribute('.gh-nav-main-editor', 'href'),13 usersHref = this.getElementAttribute('.gh-nav-main-users', 'href'),14 settingsGeneralHref = this.getElementAttribute('.gh-nav-settings-general', 'href'),15 settingsNavigationHref = this.getElementAttribute('.gh-nav-settings-navigation', 'href'),16 settingsTagsHref = this.getElementAttribute('.gh-nav-settings-tags', 'href'),17 settingsCodeInjectionHref = this.getElementAttribute('.gh-nav-settings-code-injection', 'href'),18 settingsLabsHref = this.getElementAttribute('.gh-nav-settings-labs', 'href');19 // Logo20 test.assertExists('.gh-nav-footer-sitelink', 'Ghost home page link exists in nav footer');21 test.assertEquals(logoHref, 'http://127.0.0.1:2369/', 'Ghost logo link href is correct');22 // Content23 test.assertExists('.gh-nav-main-content', 'Content nav item exists');24 test.assertSelectorHasText('.gh-nav-main-content', 'Content', 'Content nav item has correct text');25 test.assertEquals(contentHref, '/ghost/', 'Content href is correct');26 test.assertExists('.gh-nav-main-content.active', 'Content nav item is not marked active');27 // Editor28 test.assertExists('.gh-nav-main-editor', 'Editor nav item exists');29 test.assertSelectorHasText('.gh-nav-main-editor', 'New Post', 'Editor nav item has correct text');30 test.assertEquals(editorHref, '/ghost/editor/', 'Editor href is correct');31 test.assertDoesntExist('.gh-nav-main-editor.active', 'Editor nav item is not marked active');32 // Users33 test.assertExists('.gh-nav-main-users', 'Users nav item exists');34 test.assertSelectorHasText('.gh-nav-main-users', 'Team', 'Users nav item has correct text');35 test.assertEquals(usersHref, '/ghost/team/', 'Users href is correct');36 test.assertDoesntExist('.gh-nav-main-users.active', 'Users nav item is not marked active');37 // Settings - General38 test.assertExists('.gh-nav-settings-general', 'Settings - General nav exists');39 test.assertSelectorHasText('.gh-nav-settings-general', 'General', 'Settings nav item has correct text');40 test.assertEquals(settingsGeneralHref, '/ghost/settings/general/', 'Settings href is correct');41 test.assertDoesntExist('.gh-nav-settings-general.active', 'Settings nav item is marked active');42 // Settings - Navigation43 test.assertExists('.gh-nav-settings-navigation', 'Settings - Navigation nav item exists');44 test.assertSelectorHasText('.gh-nav-settings-navigation', 'Navigation', 'Settings nav item has correct text');45 test.assertEquals(settingsNavigationHref, '/ghost/settings/navigation/', 'Settings Navigation href is correct');46 test.assertDoesntExist('.gh-nav-settings-navigation.active', 'Settings - Navigation nav item is marked active');47 // Settings - Tags48 test.assertExists('.gh-nav-settings-tags', 'Settings - Tags nav item exists');49 test.assertSelectorHasText('.gh-nav-settings-tags', 'Tags', 'Settings nav item has correct text');50 test.assertEquals(settingsTagsHref, '/ghost/settings/tags/', 'Settings Navigation href is correct');51 test.assertDoesntExist('.gh-nav-settings-tags.active', 'Settings - Navigation nav item is marked active');52 // Settings - Code Injection53 test.assertExists('.gh-nav-settings-code-injection', 'Settings - Code Injection nav item exists');54 test.assertSelectorHasText('.gh-nav-settings-code-injection', 'Code Injection', 'Settings nav item has correct text');55 test.assertEquals(settingsCodeInjectionHref, '/ghost/settings/code-injection/', 'Settings Navigation href is correct');56 test.assertDoesntExist('.gh-nav-settings-code-injection.active', 'Settings - Code Injection nav item is marked active');57 // Settings - Labs58 test.assertExists('.gh-nav-settings-labs', 'Settings - Labs nav item exists');59 test.assertSelectorHasText('.gh-nav-settings-labs', 'Labs', 'Settings nav item has correct text');60 test.assertEquals(settingsLabsHref, '/ghost/settings/labs/', 'Settings Labs href is correct');61 test.assertDoesntExist('.gh-nav-settings-labs.active', 'Settings - Labs nav item is marked active');62 });63 casper.then(function testHelpMenuNotVisible() {64 test.assertExists('.gh-help-button', 'Help menu nav item exists');65 test.assertNotExists('.gh-help-button .dropdown.open', 'Help menu should not be visible');66 });67 casper.thenClick('.gh-help-button');68 casper.waitForSelector('.dropdown', function then() {69 var supportHref = this.getElementAttribute('.help-menu-support', 'href'),70 tweetHref = this.getElementAttribute('.help-menu-tweet', 'href'),71 howtoHref = this.getElementAttribute('.help-menu-how-to', 'href'),72 wishlistHref = this.getElementAttribute('.help-menu-wishlist', 'href');73 test.assertVisible('.dropdown-menu', 'Help menu should be visible');74 test.assertExists('.help-menu-support', 'Support menu item exists');75 test.assertSelectorHasText('.help-menu-support', 'Support Center', 'Support menu item has correct text');76 test.assertEquals(supportHref, 'http://support.ghost.org/', 'Support href is correct');77 test.assertExists('.help-menu-tweet', 'Tweet menu item exists');78 test.assertSelectorHasText('.help-menu-tweet', 'Tweet @TryGhost!', 'Tweet menu item has correct text');79 test.assertEquals(tweetHref, 'https://twitter.com/intent/tweet?text=%40TryGhost+Hi%21+Can+you+help+me+with+&related=TryGhost', 'Tweet href is correct');80 test.assertExists('.help-menu-how-to', 'How-to menu item exists');81 test.assertSelectorHasText('.help-menu-how-to', 'How to Use Ghost', 'How-to menu item has correct text');82 test.assertEquals(howtoHref, 'http://support.ghost.org/how-to-use-ghost/', 'How-to href is correct');83 test.assertExists('.help-menu-wishlist', 'Wishlist menu item exists');84 test.assertSelectorHasText('.help-menu-wishlist', 'Wishlist', 'Wishlist menu item has correct text');85 test.assertEquals(wishlistHref, 'http://ideas.ghost.org/', 'Wishlist href is correct');86 test.assertExists('.help-menu-markdown', 'Markdown menu item exists');87 test.assertSelectorHasText('.help-menu-markdown', 'Markdown Help', 'Markdown menu item has correct text');88 casper.thenClick('.help-menu-markdown');89 casper.waitUntilVisible('.modal-container', function onSuccess() {90 test.assertSelectorHasText(91 '.modal-content .modal-header',92 'Markdown Help',93 'delete modal has correct text');94 test.assertExists('.modal-content .close', '.modal-content .close exists');95 });96 casper.thenClick('.modal-content .close');97 casper.waitWhileVisible('.modal-container', function onSuccess() {98 test.assert(true, 'clicking close should remove the markdown help modal');99 });100 }, casper.failOnTimeout(test, 'WaitForSelector .gh-help-menu .ember-view.open failed'));101 casper.then(function testUserMenuNotVisible() {102 test.assertExists('.gh-nav-menu .gh-nav-menu-details-user', 'User menu nav item exists');103 test.assertNotExists('.gh-nav-menu-details-user .user-menu-profile', 'User menu should not be visible');104 });105 casper.thenClick('.gh-nav-menu');106 casper.waitForSelector('.dropdown', function then() {107 var profileHref = this.getElementAttribute('.user-menu-profile', 'href'),108 signoutHref = this.getElementAttribute('.user-menu-signout', 'href');109 test.assertVisible('.dropdown-item.user-menu-profile', 'User menu should be visible');110 test.assertExists('.dropdown-item.user-menu-profile', 'Profile menu item exists');111 test.assertSelectorHasText('.dropdown-item.user-menu-profile', 'Your Profile',112 'Profile menu item has correct text');113 test.assertEquals(profileHref, '/ghost/team/' + newUser.slug + '/', 'Profile href is correct');114 test.assertExists('.user-menu-signout', 'Sign Out menu item exists');115 test.assertSelectorHasText('.user-menu-signout', 'Sign Out', 'Signout menu item has correct text');116 test.assertEquals(signoutHref, '/ghost/signout/', 'Sign Out href is correct');117 }, casper.failOnTimeout(test, 'WaitForSelector .user-menu .dropdown failed'));118 // TODO Add tests to check each pane gets active class appropriately119});120CasperTest.begin('Can transition to the editor and back', 6, function suite(test) {121 casper.thenOpenAndWaitForPageLoad('root', function testTitleAndUrl() {122 test.assertTitle('Content - Test Blog', 'Ghost admin has incorrect title');...

Full Screen

Full Screen

appium-ios-tests.js

Source:appium-ios-tests.js Github

copy

Full Screen

...39 it('should find the home page text `Step One`', async function () {40 this.timeout(500000);41 client.setImplicitTimeout(100000);42 const element = await client.findElement('accessibility id', 'Step One');43 await client.getElementAttribute(element.ELEMENT, 'visible').then((attr) => {44 assert.equal(attr, 'true');45 });46 });47 it('should find the toggle element and toggle it', async function () {48 this.timeout(500000);49 client.setImplicitTimeout(100000);50 const element = await client.findElement('accessibility id', 'toggle');51 await client.getElementAttribute(element.ELEMENT, 'value').then((attr) => {52 assert.equal(attr, '0');53 });54 await client.elementClick(element.ELEMENT);55 await client.getElementAttribute(element.ELEMENT, 'value').then((attr) => {56 assert.equal(attr, '1');57 });58 });59 it('should find the search button, click it, and verify the search text `Select Country`', async function () {60 this.timeout(500000);61 client.setImplicitTimeout(100000);62 const element = await client.findElement('accessibility id', 'searchButton');63 await client.elementClick(element.ELEMENT);64 client.setImplicitTimeout(30000);65 const search_screen_element = await client.findElement('accessibility id', 'Select Country');66 await client.getElementAttribute(search_screen_element.ELEMENT, 'visible').then((attr) => {67 assert.equal(attr, 'true');68 });69 });70 it('should find the search button, click it, and return to the home page', async function () {71 this.timeout(500000);72 client.setImplicitTimeout(100000);73 const element = await client.findElement('accessibility id', 'searchButton');74 await client.elementClick(element.ELEMENT);75 client.setImplicitTimeout(300000);76 const search_screen_element = await client.findElement('accessibility id', 'header-back');77 await client.elementClick(search_screen_element.ELEMENT);78 client.setImplicitTimeout(300000);79 const home_screen_element = await client.findElement('accessibility id', 'toggle');80 await client.getElementAttribute(home_screen_element.ELEMENT, 'value').then((attr) => {81 assert.equal(attr, '0');82 });83 });84 it('should find the search button, click it, and find the first 3 countries listed', async function () {85 this.timeout(500000);86 client.setImplicitTimeout(100000);87 const element = await client.findElement('accessibility id', 'searchButton');88 await client.elementClick(element.ELEMENT);89 client.setImplicitTimeout(30000);90 const list_Item_Afghanistan = await client.findElement('accessibility id', 'listItem-Afghanistan');91 await client.getElementAttribute(list_Item_Afghanistan.ELEMENT, 'visible').then((attr) => {92 assert.equal(attr, 'true');93 });94 const list_Item_Albania = await client.findElement('accessibility id', 'listItem-Albania');95 await client.getElementAttribute(list_Item_Albania.ELEMENT, 'visible').then((attr) => {96 assert.equal(attr, 'true');97 });98 const list_Item_Algeria = await client.findElement('accessibility id', 'listItem-Algeria');99 await client.getElementAttribute(list_Item_Algeria.ELEMENT, 'visible').then((attr) => {100 assert.equal(attr, 'true');101 });102 });103 it('should find the search button, click it, enter `United States`, and verify the search box value as `United States`', async function () {104 this.timeout(500000);105 client.setImplicitTimeout(100000);106 const element = await client.findElement('accessibility id', 'searchButton');107 await client.elementClick(element.ELEMENT);108 client.setImplicitTimeout(30000);109 const search_screen_element = await client.findElement('accessibility id', 'countriesAutocompleteInput');110 await client.elementClick(search_screen_element.ELEMENT);111 await client.elementSendKeys(search_screen_element.ELEMENT, 'United States');112 client.setImplicitTimeout(30000);113 await client.getElementAttribute(search_screen_element.ELEMENT, 'value').then((attr) => {114 assert.equal(attr, 'United States');115 });116 const list_Item_United_States = await client.findElement('accessibility id', 'listItem-United States');117 await client.getElementAttribute(list_Item_United_States.ELEMENT, 'visible').then((attr) => {118 assert.equal(attr, 'true');119 });120 });121 it('should find the search bar after attempting to search again', async function () {122 this.timeout(500000);123 client.setImplicitTimeout(100000);124 const element = await client.findElement('accessibility id', 'searchButton');125 await client.elementClick(element.ELEMENT);126 client.setImplicitTimeout(30000);127 const search_screen_element = await client.findElement('accessibility id', 'countriesAutocompleteInput');128 await client.elementClick(search_screen_element.ELEMENT);129 await client.elementSendKeys(search_screen_element.ELEMENT, 'United States');130 client.setImplicitTimeout(30000);131 await client.getElementAttribute(search_screen_element.ELEMENT, 'value').then((attr) => {132 assert.equal(attr, 'United States');133 });134 const list_Item_United_States = await client.findElement('accessibility id', 'listItem-United States');135 await client.getElementAttribute(list_Item_United_States.ELEMENT, 'visible').then((attr) => {136 assert.equal(attr, 'true');137 });138 // Extension139 const back_button_element = await client.findElement('accessibility id', 'header-back');140 await client.elementClick(back_button_element.ELEMENT);141 client.setImplicitTimeout(30000);142 const search_buttom_element = await client.findElement('accessibility id', 'searchButton');143 await client.elementClick(search_buttom_element.ELEMENT);144 client.setImplicitTimeout(30000);145 146 const search_screen_on_return_element = await client.findElement('accessibility id', 'countriesAutocompleteInput');147 await client.getElementAttribute(search_screen_on_return_element.ELEMENT, 'visible').then((attr) => {148 assert.equal(attr, 'true');149 });150 });151 it('shouldn\'t find the search bar after attempting to search again after clicking on a result', async function () {152 this.timeout(500000);153 client.setImplicitTimeout(100000);154 const element = await client.findElement('accessibility id', 'searchButton');155 await client.elementClick(element.ELEMENT);156 client.setImplicitTimeout(30000);157 const search_screen_element = await client.findElement('accessibility id', 'countriesAutocompleteInput');158 await client.elementClick(search_screen_element.ELEMENT);159 await client.elementSendKeys(search_screen_element.ELEMENT, 'United States');160 client.setImplicitTimeout(30000);161 await client.getElementAttribute(search_screen_element.ELEMENT, 'value').then((attr) => {162 assert.equal(attr, 'United States');163 });164 const list_Item_United_States = await client.findElement('accessibility id', 'listItem-United States');165 await client.getElementAttribute(list_Item_United_States.ELEMENT, 'visible').then((attr) => {166 assert.equal(attr, 'true');167 });168 // Extension169 await client.elementClick(list_Item_United_States.ELEMENT);170 client.setImplicitTimeout(30000);171 const back_button_element = await client.findElement('accessibility id', 'header-back');172 await client.elementClick(back_button_element.ELEMENT);173 client.setImplicitTimeout(30000);174 const search_buttom_element = await client.findElement('accessibility id', 'searchButton');175 await client.elementClick(search_buttom_element.ELEMENT);176 client.setImplicitTimeout(30000);177 isPresent = false;178 try {179 await client.findElement('accessibility id', 'countriesAutocompleteInput');180 assert.equal(isPresent, true);181 } catch(error) {182 assert.equal(isPresent, false);183 }184 });185 it ('shouldn\'t find the home page text `Networking How to use the Fetch API in React Native.`', async function () {186 this.timeout(500000);187 client.setImplicitTimeout(100000);188 const element = await client.findElement('accessibility id', 'Networking How to use the Fetch API in React Native.');189 await client.getElementAttribute(element.ELEMENT, 'visible').then((attr) => {190 assert.equal(attr, 'false');191 });192 });193 it ('should find the home page text `Networking How to use the Fetch API in React Native.` if scrolled to bottom', async function () {194 this.timeout(500000);195 client.setImplicitTimeout(100000);196 const element = await client.findElement('accessibility id', 'Networking How to use the Fetch API in React Native.');197 await client.execute("mobile: scroll", {direction: 'down'});198 await client.getElementAttribute(element.ELEMENT, 'visible').then((attr) => {199 assert.equal(attr, 'true');200 });201 });...

Full Screen

Full Screen

Frontend.js

Source:Frontend.js Github

copy

Full Screen

...15casper.then(function(){16 x = require('casper').selectXPath;17 casper.waitUntilVisible(x("//*[text()='CasperTestQuestion']"), function(){18 test.assertExists(x("//*[text()='CasperTestQuestion']"), 'Created question');19 idobject = this.getElementAttribute(x("//*[text()='CasperTestQuestion']"), 'id');20 id = /(\d+)/.exec(idobject);21 id=id[0];22 this.click("h1#" + idobject);23 this.fill('form#questionform_' + id, {24 'question': 'CasperEDITED'25 }, false);26 this.click("input#questioneditsubmit_" + id);27 });28});29// Flag/unflag question30casper.then(function(){31 casper.waitUntilVisible(x("//*[text()='CasperEDITED']"), function(){32 test.assertExists(x("//*[text()='CasperEDITED']"), 'Edited question')33 this.click("div#flagcontainer_" + id);34 casper.waitUntilVisible("img#flag_" + id, function (){35 test.assertNotEquals(this.getElementAttribute("img#flag_" + id, 'src').indexOf('red'), -1, 'Changed question flag image to red');36 this.click("div#flagcontainer_" + id);37 casper.waitUntilVisible("img#flag_" + id, function(){38 test.assertEquals(this.getElementAttribute("img#flag_" + id, 'src').indexOf('red'), -1, 'Changed question flag image to gray');39 });40 });41 });42});43//Vote down on question44casper.then(function(){45 casper.waitUntilVisible("p#count_" + id, function(){46 var count = this.fetchText("p#count_" + id);47 this.click("img#down_" + id);48 casper.waitUntilVisible("img#down_" + id, function(){49 test.assertNotEquals(this.getElementAttribute("img#down_" + id, 'src').indexOf('clicked'), -1, 'Changed downvote image');50 test.assertEquals(this.getElementAttribute("img#up_" + id, 'src').indexOf('clicked'), -1, "Didn't change upvote image");51 casper.waitUntilVisible("p#count_" + id, function(){52 test.assertEquals(Number(this.fetchText("p#count_" + id)), (Number(count) - 1), "Voted down on question");53 });54 });55 });56});57//Vote up on question58casper.then(function(){59 casper.waitUntilVisible("p#count_" + id, function(){60 var count = this.fetchText("p#count_" + id);61 this.click("img#up_" + id);62 casper.waitUntilVisible("img#up_" + id, function(){63 test.assertNotEquals(this.getElementAttribute("img#up_" + id, 'src').indexOf('clicked'), -1, 'Changed upvote image');64 test.assertEquals(this.getElementAttribute("img#down_" + id, 'src').indexOf('clicked'), -1, "Didn't change downvote image");65 casper.waitUntilVisible("p#count_" + id, function(){66 test.assertEquals(Number(this.fetchText("p#count_" + id)), (Number(count) + 2), "Voted up on question");67 });68 });69 });70});71//Add comment72casper.then(function(){73 this.click("h4#reply_" + id);74 casper.waitUntilVisible("form#commentform_" + id, function(){75 this.fill('form#commentform_' + id, {76 'comment': 'CasperComment'77 }, false);78 this.click("input#submit_" + id);79 casper.waitUntilVisible(x("//*[normalize-space()='CasperComment']"), function(){80 idobject = this.getElementAttribute(x("//*[normalize-space()='CasperComment']"), 'id');81 commentid = /(\d+)/.exec(idobject);82 commentid=commentid[0];83 });84 });85});86//Edit comment87casper.then(function(){88 this.click("span#" + idobject);89 test.assertExists("form#editcommentform_" + id, "Found edit comment form");90 this.fill('form#editcommentform_' + id, {91 'comment': 'CasperCommentEDITED'92 }, false);93 this.click("input#editsubmit_" + id);94 this.waitUntilVisible("span#" + idobject, function(){95 test.assertEquals(this.fetchText("span#" + idobject), 'CasperCommentEDITED', "Edited comment");96 });97});98// Flag/unflag comment99casper.then(function(){100 casper.waitUntilVisible("img#commentflag_" + commentid, function(){101 this.click("img#commentflag_" + commentid);102 casper.waitUntilVisible("img#commentflag_" + commentid, function(){ 103 test.assertNotEquals(this.getElementAttribute("img#commentflag_" + commentid, 'src').indexOf('red'), -1, 'Changed comment flag image to red');104 this.click("img#commentflag_" + commentid);105 casper.waitUntilVisible("img#commentflag_" + commentid, function(){106 test.assertEquals(this.getElementAttribute("img#commentflag_" + commentid, 'src').indexOf('red'), -1, 'Changed comment flag image to gray');107 });108 });109 });110});111// Vote down on comment112casper.then(function(){113 var count = this.fetchText("span#commentvotecount_" + commentid);114 this.click("img#commentdown_" + commentid);115 casper.waitUntilVisible("img#commentdown_" + commentid, function(){116 test.assertNotEquals(this.getElementAttribute("img#commentdown_" + commentid, 'src').indexOf('clicked'), -1, 'Changed comment downvote image');117 test.assertEquals(this.getElementAttribute("img#commentup_" + commentid, 'src').indexOf('clicked'), -1, "Didn't change comment upvote image");118 casper.waitUntilVisible("span#commentvotecount_" + commentid, function(){119 test.assertEquals(Number(this.fetchText("span#commentvotecount_" + commentid)), (Number(count) - 1), "Voted down on comment");120 });121 });122});123// Vote up on comment124casper.then(function(){125 var count = this.fetchText("span#commentvotecount_" + commentid);126 this.click("img#commentup_" + commentid);127 casper.waitUntilVisible("img#commentup_" + commentid, function(){128 test.assertNotEquals(this.getElementAttribute("img#commentup_" + commentid, 'src').indexOf('clicked'), -1, 'Changed comment upvote image');129 test.assertEquals(this.getElementAttribute("img#commentdown_" + commentid, 'src').indexOf('clicked'), -1, "Didn't change comment downvote image");130 casper.waitUntilVisible("span#commentvotecount_" + commentid, function(){131 test.assertEquals(Number(this.fetchText("span#commentvotecount_" + commentid)), (Number(count) + 2), "Voted up on comment");132 });133 });134});135// Mark/unmark/swap comment as answer136casper.then(function(){137 this.click("img#markanswer_" + commentid);138 casper.waitUntilVisible("img#markanswer_" + commentid, function(){139 test.assertNotEquals(this.getElementAttribute("img#markanswer_" + commentid, 'src').indexOf('checked'), -1, 'Marked comment as answer');140 this.click("img#markanswer_" + commentid);141 casper.waitUntilVisible("img#markanswer_" + commentid, function(){142 test.assertEquals(this.getElementAttribute("img#markanswer_" + commentid, 'src').indexOf('checked'), -1, 'Unmarked comment as answer');143 this.click("h4#reply_" + id);144 casper.waitUntilVisible("form#commentform_" + id, function(){145 this.fill('form#commentform_' + id, {146 'comment': 'CasperComment2'147 }, false);148 this.click("input#submit_" + id);149 casper.waitUntilVisible(x("//*[normalize-space()='CasperComment2']"), function(){150 idobject2 = this.getElementAttribute(x("//*[normalize-space()='CasperComment2']"), 'id');151 commentid2 = /(\d+)/.exec(idobject2);152 commentid2=commentid2[0];153 this.click("img#markanswer_" + commentid2);154 casper.waitUntilVisible("img#markanswer_" + commentid2, function(){155 test.assertNotEquals(this.getElementAttribute("img#markanswer_" + commentid2, 'src').indexOf('checked'), -1, 'Marked second comment as answer');156 test.assertEquals(this.getElementAttribute("img#markanswer_" + commentid, 'src').indexOf('checked'), -1, 'Unmarked first comment as answer');157 this.click("img#markanswer_" + commentid2);158 });159 });160 });161 });162 });163});164// Delete comment165casper.then(function(){166 this.click("img#delete_" + commentid);167 casper.waitWhileVisible("img#delete_" + commentid, function(){168 test.assertDoesntExist("div#comment_" + commentid, 'Deleted comment');169 });170 ...

Full Screen

Full Screen

test-amp-autocomplete-inline.js

Source:test-amp-autocomplete-inline.js Github

copy

Full Screen

...32 await expect(33 controller.getElementProperty(autocomplete, 'children')34 ).to.have.length(3);35 const input = await controller.findElement('#input');36 await expect(controller.getElementAttribute(input, 'type')).to.equal(37 'text'38 );39 const script = await controller.findElement('#script');40 await expect(controller.getElementAttribute(script, 'type')).to.equal(41 'application/json'42 );43 const renderedResults = await controller.findElement(44 '.i-amphtml-autocomplete-results'45 );46 await expect(47 controller.getElementProperty(renderedResults, 'children')48 ).to.have.length(3);49 await expect(controller.getElementAttribute(renderedResults, 'hidden'))50 .not.to.be.null;51 });52 it('<amp-autocomplete inline> should display results on trigger', async () => {53 const renderedResults = await controller.findElement(54 '.i-amphtml-autocomplete-results'55 );56 await expect(57 controller.getElementProperty(renderedResults, 'children')58 ).to.have.length(3);59 // Does not display suggested items on blur.60 await expect(controller.getElementAttribute(renderedResults, 'hidden'))61 .not.to.be.null;62 const focusButton = await controller.findElement('#focusButton');63 await controller.click(focusButton);64 // Does not display suggested items on focus.65 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to66 .not.to.be.null;67 // Does not display suggested items on any input.68 await controller.type(input, 'ap');69 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to70 .not.to.be.null;71 // Displays suggested items on trigger.72 const input = await controller.findElement('#input');73 await controller.type(input, ' @');74 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to75 .to.be.null;76 });77 it('<amp-autocomplete inline> should narrow suggestions to input', async () => {78 const renderedResults = await controller.findElement(79 '.i-amphtml-autocomplete-results'80 );81 const focusButton = await controller.findElement('#focusButton');82 await expect(controller.getElementAttribute(renderedResults, 'hidden'))83 .not.to.be.null;84 await controller.click(focusButton);85 // Displays all suggested items on trigger.86 const input = await controller.findElement('#input');87 await controller.type(input, '@');88 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to89 .to.be.null;90 await expect(91 controller.getElementProperty(renderedResults, 'children')92 ).to.have.length(3);93 // New input narrows down suggested items.94 await controller.type(input, 'ap');95 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to96 .be.null;97 await expect(98 controller.getElementProperty(renderedResults, 'children')99 ).to.have.length(1);100 });101 it('<amp-autocomplete inline> should select an item', async () => {102 const renderedResults = await controller.findElement(103 '.i-amphtml-autocomplete-results'104 );105 const focusButton = await controller.findElement('#focusButton');106 await expect(controller.getElementAttribute(renderedResults, 'hidden'))107 .not.to.be.null;108 await expect(109 controller.getElementProperty(renderedResults, 'children')110 ).to.have.length(3);111 // Displays all suggested items on trigger.112 const input = await controller.findElement('#input');113 await controller.click(focusButton);114 await controller.type(input, '@');115 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to116 .be.null;117 const itemElements = await controller.findElements(118 '.i-amphtml-autocomplete-item'119 );120 await expect(controller.getElementText(itemElements[0])).to.equal(121 'apple'122 );123 await controller.click(itemElements[0]);124 // Displays no items after selecting one.125 await expect(controller.getElementAttribute(renderedResults, 'hidden'))126 .not.to.be.null;127 await expect(controller.getElementProperty(input, 'value')).to.equal(128 '@apple '129 );130 });131 }...

Full Screen

Full Screen

test-amp-autocomplete.js

Source:test-amp-autocomplete.js Github

copy

Full Screen

...32 await expect(33 controller.getElementProperty(autocomplete, 'children')34 ).to.have.length(3);35 const input = await controller.findElement('#input');36 await expect(controller.getElementAttribute(input, 'type')).to.equal(37 'text'38 );39 const script = await controller.findElement('#script');40 await expect(controller.getElementAttribute(script, 'type')).to.equal(41 'application/json'42 );43 const renderedResults = await controller.findElement(44 '.i-amphtml-autocomplete-results'45 );46 await expect(47 controller.getElementProperty(renderedResults, 'children')48 ).to.have.length(3);49 await expect(controller.getElementAttribute(renderedResults, 'hidden'))50 .not.to.be.null;51 });52 it('<amp-autocomplete> should display results on focus', async () => {53 const renderedResults = await controller.findElement(54 '.i-amphtml-autocomplete-results'55 );56 await expect(57 controller.getElementProperty(renderedResults, 'children')58 ).to.have.length(3);59 await expect(controller.getElementAttribute(renderedResults, 'hidden'))60 .not.to.be.null;61 const focusButton = await controller.findElement('#focusButton');62 await controller.click(focusButton);63 // Displays all suggested items on focus.64 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to65 .be.null;66 });67 it('<amp-autocomplete> should narrow suggestions to input', async () => {68 const renderedResults = await controller.findElement(69 '.i-amphtml-autocomplete-results'70 );71 const focusButton = await controller.findElement('#focusButton');72 await expect(controller.getElementAttribute(renderedResults, 'hidden'))73 .not.to.be.null;74 await controller.click(focusButton);75 // Displays all suggested items on focus.76 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to77 .be.null;78 await expect(79 controller.getElementProperty(renderedResults, 'children')80 ).to.have.length(3);81 // New input narrows down suggested items.82 const input = await controller.findElement('#input');83 await controller.type(input, 'an');84 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to85 .be.null;86 await expect(87 controller.getElementProperty(renderedResults, 'children')88 ).to.have.length(2);89 });90 it('<amp-autocomplete> should select an item', async () => {91 const renderedResults = await controller.findElement(92 '.i-amphtml-autocomplete-results'93 );94 const focusButton = await controller.findElement('#focusButton');95 await expect(controller.getElementAttribute(renderedResults, 'hidden'))96 .not.to.be.null;97 await expect(98 controller.getElementProperty(renderedResults, 'children')99 ).to.have.length(3);100 // Displays all suggested items on focus.101 await controller.click(focusButton);102 await expect(controller.getElementAttribute(renderedResults, 'hidden')).to103 .be.null;104 const itemElements = await controller.findElements(105 '.i-amphtml-autocomplete-item'106 );107 await expect(controller.getElementText(itemElements[0])).to.equal(108 'apple'109 );110 await controller.click(itemElements[0]);111 // Displays no items after selecting one.112 await expect(controller.getElementAttribute(renderedResults, 'hidden'))113 .not.to.be.null;114 await expect(115 controller.getElementProperty(renderedResults, 'children')116 ).to.have.length(1);117 const input = await controller.findElement('#input');118 await expect(controller.getElementProperty(input, 'value')).to.equal(119 'apple'120 );121 });122 }...

Full Screen

Full Screen

test-amp-bind-video.js

Source:test-amp-bind-video.js Github

copy

Full Screen

...26 });27 it('should support binding to src', async () => {28 const button = await controller.findElement('#changeVidSrcButton');29 const video = await controller.findElement('#video');30 await expect(controller.getElementAttribute(video, 'src')).to.equal(31 'https://www.google.com/unbound.webm'32 );33 await controller.click(button);34 await expect(controller.getElementAttribute(video, 'src')).to.equal(35 'https://www.google.com/bound.webm'36 );37 });38 it('should NOT change src when new value is a blocked URL', async () => {39 const button = await controller.findElement('#disallowedVidUrlButton');40 const video = await controller.findElement('#video');41 await expect(controller.getElementAttribute(video, 'src')).to.equal(42 'https://www.google.com/unbound.webm'43 );44 await controller.click(button);45 await expect(controller.getElementAttribute(video, 'src')).to.equal(46 'https://www.google.com/unbound.webm'47 );48 });49 it('should NOT change src when new value uses an invalid protocol', async () => {50 const button = await controller.findElement('#httpVidSrcButton');51 const video = await controller.findElement('#video');52 await expect(controller.getElementAttribute(video, 'src')).to.equal(53 'https://www.google.com/unbound.webm'54 );55 await controller.click(button);56 // Only HTTPS is allowed57 await expect(controller.getElementAttribute(video, 'src')).to.equal(58 'https://www.google.com/unbound.webm'59 );60 });61 it('should change alt when the alt attribute binding changes', async () => {62 const button = await controller.findElement('#changeVidAltButton');63 const video = await controller.findElement('#video');64 await expect(controller.getElementAttribute(video, 'alt')).to.equal(65 'unbound'66 );67 await controller.click(button);68 await expect(controller.getElementAttribute(video, 'alt')).to.equal(69 'hello world'70 );71 });72 it('should show/hide vid controls when the control binding changes', async () => {73 const showButton = await controller.findElement('#showVidControlsButton');74 const hideButton = await controller.findElement('#hideVidControlsButton');75 const video = await controller.findElement('#video');76 await expect(controller.getElementAttribute(video, 'controls')).to.be77 .null;78 await controller.click(showButton);79 await expect(controller.getElementAttribute(video, 'controls')).to.not.be80 .null;81 await controller.click(hideButton);82 await expect(controller.getElementAttribute(video, 'controls')).to.be83 .null;84 });85 }...

Full Screen

Full Screen

browser_inspector_highlighter-geometry_04.js

Source:browser_inspector_highlighter-geometry_04.js Github

copy

Full Screen

...45 }46}47function* checkArrowAndHandler({getElementAttribute}, name, expectedCoords) {48 info("Checking " + name + "arrow and handler coordinates are correct");49 let handlerX = yield getElementAttribute("handler-" + name, "cx");50 let handlerY = yield getElementAttribute("handler-" + name, "cy");51 let expectedHandlerX = yield getElementAttribute("arrow-" + name,52 handlerMap[name].cx);53 let expectedHandlerY = yield getElementAttribute("arrow-" + name,54 handlerMap[name].cy);55 is(handlerX, expectedHandlerX,56 "coordinate X for handler " + name + " is correct.");57 is(handlerY, expectedHandlerY,58 "coordinate Y for handler " + name + " is correct.");59 for (let coordinate in expectedCoords) {60 let value = yield getElementAttribute("arrow-" + name, coordinate);61 is(Math.floor(value), expectedCoords[coordinate],62 coordinate + " coordinate for arrow " + name + " is correct");63 }...

Full Screen

Full Screen

elementattribute.js

Source:elementattribute.js Github

copy

Full Screen

1/*global casper*/2/*jshint strict:false*/3var x = require('casper').selectXPath;4casper.test.begin('getElementAttribute() tests', 4, function(test) {5 casper.start('tests/site/elementattribute.html', function() {6 test.assertEquals(this.getElementAttribute('.testo', 'data-stuff'),7 'beautiful string', 'Casper.getElementAttribute() works with a CSS selector');8 test.assertEquals(this.getElementAttribute(x('//div[@class]'), 'data-stuff'),9 'beautiful string', 'Casper.getElementAttribute() works with a XPath selector');10 }).then(function() {11 test.assertEquals(this.getElementsAttribute('.testo', 'data-stuff'),12 ['beautiful string', 'not as beautiful string'],13 'Casper.getElementsAttribute() works with a CSS selector');14 test.assertEquals(this.getElementsAttribute(x('//div[@class]'), 'data-stuff'),15 ['beautiful string', 'not as beautiful string'],16 'Casper.getElementsAttribute() works with a XPath selector');17 }).run(function() {18 test.done();19 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getAttribute('[name="q"]', 'value', function(err, result) {9 })10 .end();11var webdriverio = require('webdriverio');12var options = {13 desiredCapabilities: {14 }15};16 .remote(options)17 .init()18 .getAttributeFromDOM('[name="q"]', 'value', function(err, result) {19 })20 .end();21var webdriverio = require('webdriverio');22var options = {23 desiredCapabilities: {24 }25};26 .remote(options)27 .init()28 .getCSSProperty('[name="q"]', 'display', function(err, result) {29 })30 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getElementAttribute('#lst-ib', 'value', function(err, result) {6 })7 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .getValue('#lst-ib').then(function(value) {9 console.log('Value was: ' + value);10 })11 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 console.log('Title is: ' + title);5 })6 it('should have the right title', () => {7 const title = browser.getTitle();8 console.log('Title is: ' + title);9 })10 it('should have the right title', () => {11 const title = browser.getTitle();12 console.log('Title is: ' + title);13 })14 it('should have the right title', () => {15 const title = browser.getTitle();16 console.log('Title is: ' + title);17 })18 it('should have the right title', () => {19 const title = browser.getTitle();20 console.log('Title is: ' + title);21 })22})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 console.log('Title is: ' + title);5 });6});7describe('webdriver.io page', () => {8 it('should have the right title', () => {9 const title = browser.getTitle();10 console.log('Title is: ' + title);11 });12});13describe('webdriver.io page', () => {14 it('should have the right title', () => {15 const title = browser.getTitle();16 console.log('Title is: ' + title);17 });18});19describe('webdriver.io page', () => {20 it('should have the right title', () => {21 const title = browser.getTitle();22 console.log('Title is: ' + title);23 });24});25describe('webdriver.io page', () => {26 it('should have the right title', () => {27 const title = browser.getTitle();28 console.log('Title is: ' + title);29 });30});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .getValue('#lst-ib').then(function(value) {9 console.log('Value was: ' + value);10 })11 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 console.log('Title is: ' + title);5 });6});7describe('webdriver.io page', () => {8 it('should have the right title', () => {9 const title = browser.getTitle();10 console.log('Title is: ' + title);11 });12});13describe('webdriver.io page', () => {14 it('should have the right title', () => {15 const title = browser.getTitle();16 console.log('Title is: ' + title);17 });18});19describe('webdriver.io page', () => {20 it('should have the right title', () => {21 const title = browser.getTitle();22 console.log('Title is: ' + title);23 });24});25describe('webdriver.io page', () => {26 it('should have the right title', () => {27 const title = browser.getTitle();28 console.log('Title is: ' + title);29 });30});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 console.log('Title is: ' + title);5 });6});7describe('webdriver.io page', () => {8 it('should have the right title', () => {9 const title = browser.getTitle();10 console.log('Title is: ' + title);11 });12});13describe('webdriver.io page', () => {14 it('should have the right title', () => {15 const title = browser.getTitle();16 console.log('Title is: ' + title);17 });18});19describe('webdriver.io page', () => {20 it('should have the right title', () => {21 const title = browser.getTitle();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test to get the value of an attribute', () => {2 it('should get the value of an attribute', () => {3 const title = browser.getTitle()4 console.log('Title is: ' + title)5 const value = browser.getAttribute('input[name="q"]', 'title')6 console.log('Value of the title attribute of the search box is: ' + value)7 })8}) console.log('Title is: ' + title);9 });10});11describe('webdriver.io page', () => {12 it('should have the right title', () => {13 const title = browser.getTitle();14 console.log('Title is: ' + title);15 });16});17describe('webdriver.io page', () => {18 it('should have the right title', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 console.log('Title is: ' + title);5 });6 it('should get the element attribute', () => {7 console.log('Attribute value is: ' + attribute);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('WebdriverIO API Demos', function() {2 it('getElementAttribute', function () {3 const title = browser.getTitle();4 console.log('Title is: ' + title);5 console.log('href value is: ' + href);6 browser.pause(3000);7 });8});

Full Screen

Using AI Code Generation

copy

Full Screen

1const assert = require('assert');2describe('Test webdriveruni homepage', () => {3 it('Check that the contact us button opens the contact us page', () => {4 browser.url('/');5 const value = browser.getAttribute('#contact-us', 'class');6 console.log(value);7 assert.strictEqual(value, 'contact-us');8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test to get the value of an attribute', () => {2 it('should get the value of an attribute', () => {3 const title = browser.getTitle()4 console.log('Title is: ' + title)5 const value = browser.getAttribute('input[name="q"]', 'title')6 console.log('Value of the title attribute of the search box is: ' + value)7 })8})

Full Screen

WebdriverIO Tutorial

Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.

Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.

Chapters

  1. Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.

  2. Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.

  3. Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?

  4. Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.

  5. How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.

  6. Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.

  7. Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.

  8. Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.

  9. JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.

  10. Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.

Run Webdriverio automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful