Best JavaScript code snippet using wpt
getElementAttribute.spec.js
Source:getElementAttribute.spec.js
...39 });40};41describe("iOS", () => {42 beforeEach(() => setPlatform("iOS"));43 testAttribute({44 attribute: "UID",45 rawValue: "6A000000-0000-0000-D847-000000000000",46 value: "6A000000-0000-0000-D847-000000000000"47 });48 testAttribute({49 attribute: "accessibilityContainer",50 rawValue: "false",51 value: false52 });53 testAttribute({54 attribute: "accessible",55 rawValue: "true",56 value: true57 });58 testAttribute({59 attribute: "enabled",60 rawValue: "true",61 value: true62 });63 // TODO: Get 500 error from Appium: "Invalid type in JSON write (NSConcreteValue)".64 // testAttribute({65 // attribute: "frame",66 // rawValue: null,67 // value: null68 // });69 testAttribute({70 attribute: "label",71 rawValue: "test",72 value: "test"73 });74 testAttribute({75 attribute: "name",76 rawValue: "button",77 value: "button"78 });79 testAttribute({80 attribute: "rect",81 rawValue: `{ "y": 105, "x": 17, "width": 342, "height": 33 }`,82 value: { y: 105, x: 17, width: 342, height: 33 }83 });84 testAttribute({85 attribute: "selected",86 rawValue: "false",87 value: false88 });89 testAttribute({90 attribute: "type",91 rawValue: "XCUIElementTypeTextField",92 value: "XCUIElementTypeTextField"93 });94 // Note: null when input is empty otherwise a string.95 testAttribute({96 attribute: "value",97 rawValue: null,98 value: null99 });100 testAttribute({101 attribute: "visible",102 rawValue: "true",103 value: true104 });105 testAttribute({106 attribute: "wdAccessibilityContainer",107 rawValue: "false",108 value: false109 });110 testAttribute({111 attribute: "wdAccessible",112 rawValue: "true",113 value: true114 });115 testAttribute({116 attribute: "wdEnabled",117 rawValue: "true",118 value: true119 });120 // TODO: Get 500 error from Appium: "Invalid type in JSON write (NSConcreteValue)".121 // testAttribute({122 // attribute: "wdFrame",123 // rawValue: null,124 // value: null125 // });126 testAttribute({127 attribute: "wdLabel",128 rawValue: "test",129 value: "test"130 });131 testAttribute({132 attribute: "wdName",133 rawValue: "button",134 value: "button"135 });136 testAttribute({137 attribute: "wdRect",138 rawValue: `{ "y": 105, "x": 17, "width": 342, "height": 33 }`,139 value: { y: 105, x: 17, width: 342, height: 33 }140 });141 testAttribute({142 attribute: "wdSelected",143 rawValue: "false",144 value: false145 });146 testAttribute({147 attribute: "wdType",148 rawValue: "XCUIElementTypeTextField",149 value: "XCUIElementTypeTextField"150 });151 // Note: null when input is empty otherwise a string.152 testAttribute({153 attribute: "wdValue",154 rawValue: null,155 value: null156 });157 testAttribute({158 attribute: "wdVisible",159 rawValue: "true",160 value: true161 });162 testAttribute({163 attribute: "wdUID",164 rawValue: "6A000000-0000-0000-D847-000000000000",165 value: "6A000000-0000-0000-D847-000000000000"166 });167});168describe("Android", () => {169 beforeEach(() => setPlatform("Android"));170 testAttribute({171 attribute: "checkable",172 rawValue: "true",173 value: true174 });175 testAttribute({176 attribute: "checked",177 rawValue: "false",178 value: false179 });180 testAttribute({181 attribute: "class",182 rawValue: "android.widget.EditText",183 value: "android.widget.EditText"184 });185 testAttribute({186 attribute: "className",187 rawValue: "android.widget.EditText",188 value: "android.widget.EditText"189 });190 testAttribute({191 attribute: "clickable",192 rawValue: "true",193 value: true194 });195 testAttribute({196 attribute: "content-desc",197 rawValue: "button",198 value: "button"199 });200 testAttribute({201 attribute: "contentDescription",202 rawValue: "button",203 value: "button"204 });205 testAttribute({206 attribute: "enabled",207 rawValue: "false",208 value: false209 });210 testAttribute({211 attribute: "focusable",212 rawValue: "true",213 value: true214 });215 testAttribute({216 attribute: "focused",217 rawValue: "false",218 value: false219 });220 testAttribute({221 attribute: "long-clickable",222 rawValue: "true",223 value: true224 });225 testAttribute({226 attribute: "longClickable",227 rawValue: "true",228 value: true229 });230 testAttribute({231 attribute: "package",232 rawValue: "com.nativedemoapp",233 value: "com.nativedemoapp"234 });235 testAttribute({236 attribute: "password",237 rawValue: "false",238 value: false239 });240 testAttribute({241 attribute: "resource-id",242 rawValue: null,243 value: null244 });245 testAttribute({246 attribute: "resourceId",247 rawValue: null,248 value: null249 });250 testAttribute({251 attribute: "scrollable",252 rawValue: "true",253 value: true254 });255 testAttribute({256 attribute: "selection-start",257 rawValue: null,258 value: null259 });260 testAttribute({261 attribute: "selection-end",262 rawValue: null,263 value: null264 });265 testAttribute({266 attribute: "selected",267 rawValue: "false",268 value: false269 });270 testAttribute({271 attribute: "name",272 rawValue: "test",273 value: "test"274 });275 testAttribute({276 attribute: "text",277 rawValue: "test",278 value: "test"279 });280 testAttribute({281 attribute: "bounds",282 rawValue: "[42,252][1038,372]",283 value: { x1: 42, y1: 252, x2: 1038, y2: 372 }284 });285 testAttribute({286 attribute: "displayed",287 rawValue: "true",288 value: true289 });290 testAttribute({291 attribute: "contentSize",292 rawValue: `{ "width": 1080, "height": 1584, "top": 210, "left": 0, "scrollableOffset": 2545, "touchPadding": 21 }`,293 value: { width: 1080, height: 1584, top: 210, left: 0, scrollableOffset: 2545, touchPadding: 21 }294 });295});296describe("Web", () => {297 beforeEach(() => setPlatform("Web"));298 it("supports any attribute", async () => {299 const sessionId = "sessionId";300 const ref = createFindElementMock();301 const attribute = "class";302 const value = "test";303 jest.spyOn(sessionStore, "getSessionId").mockReturnValue(sessionId);304 jest.spyOn(requestHelpers, "request").mockResolvedValue(value);...
test_search.js
Source:test_search.js
1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4/*5 * Testing of general mail search features.6 *7 * This tests some search attributes not tested by other specific tests,8 * e.g., test_searchTag.js or test_searchJunk.js9 */10load("../../../resources/searchTestUtils.js");11const copyService = Cc["@mozilla.org/messenger/messagecopyservice;1"]12 .getService(Ci.nsIMsgCopyService);13const nsMsgSearchScope = Ci.nsMsgSearchScope;14const nsMsgSearchAttrib = Ci.nsMsgSearchAttrib;15const nsMsgSearchOp = Ci.nsMsgSearchOp;16const Isnt = nsMsgSearchOp.Isnt;17const Is = nsMsgSearchOp.Is;18const IsEmpty = nsMsgSearchOp.IsEmpty;19const IsntEmpty = nsMsgSearchOp.IsntEmpty;20const Contains = nsMsgSearchOp.Contains;21const DoesntContain = nsMsgSearchOp.DoesntContain;22const BeginsWith = nsMsgSearchOp.BeginsWith;23const EndsWith = nsMsgSearchOp.EndsWith;24const IsBefore = nsMsgSearchOp.IsBefore; // control entry not enabled25const offlineMail = nsMsgSearchScope.offlineMail;26const onlineMail = nsMsgSearchScope.onlineMail;27const offlineMailFilter = nsMsgSearchScope.offlineMailFilter;28const onlineMailFilter = nsMsgSearchScope.onlineMailFilter;29const news = nsMsgSearchScope.news; // control entry not enabled30const OtherHeader = nsMsgSearchAttrib.OtherHeader;31const From = nsMsgSearchAttrib.Sender;32const Subject = nsMsgSearchAttrib.Subject;33var Tests =34[35 // test the To: header36 { testString: "PrimaryEmail1@test.invalid",37 testAttribute: From,38 op: Is,39 count: 1 },40 { testString: "PrimaryEmail1@test.invalid",41 testAttribute: From,42 op: Isnt,43 count: 0 },44 { testString: "PrimaryEmail",45 testAttribute: From,46 op: BeginsWith,47 count: 1 },48 { testString: "invalid",49 testAttribute: From,50 op: BeginsWith,51 count: 0 },52 { testString: "invalid",53 testAttribute: From,54 op: EndsWith,55 count: 1},56 { testString: "Primary",57 testAttribute: From,58 op: EndsWith,59 count: 0},60 { testString: "QAContact",61 testAttribute: OtherHeader,62 op: BeginsWith,63 count: 1},64 { testString: "filters",65 testAttribute: OtherHeader,66 op: BeginsWith,67 count: 0},68 { testString: "mail.bugs",69 testAttribute: OtherHeader,70 op: EndsWith,71 count: 1},72 { testString: "QAContact",73 testAttribute: OtherHeader,74 op: EndsWith,75 count: 0},76 { testString: "QAcontact filters@mail.bugs",77 testAttribute: OtherHeader,78 op: Is,79 count: 1},80 { testString: "filters@mail.bugs",81 testAttribute: OtherHeader,82 op: Is,83 count: 0},84 { testString: "QAcontact filters@mail.bugs",85 testAttribute: OtherHeader,86 op: Isnt,87 count: 0},88 { testString: "QAcontact",89 testAttribute: OtherHeader,90 op: Isnt,91 count: 1},92 { testString: "filters",93 testAttribute: OtherHeader,94 op: Contains,95 count: 1},96 { testString: "foobar",97 testAttribute: OtherHeader,98 op: Contains,99 count: 0},100 // test accumulation of received header101 // only in first received102 { testString: "caspiaco",103 testAttribute: OtherHeader,104 op: Contains,105 customHeader: "Received",106 count: 1},107 // only in second108 { testString: "webapp01.sj.mozilla.com",109 testAttribute: OtherHeader,110 op: Contains,111 customHeader: "received",112 count: 1},113 // in neither114 { testString: "not there",115 testAttribute: OtherHeader,116 op: Contains,117 customHeader: "received",118 count: 0},119 // test multiple line arbitrary headers120 // in the first line121 { testString: "SpamAssassin 3.2.3",122 testAttribute: OtherHeader,123 op: Contains,124 customHeader: "X-Spam-Checker-Version",125 count: 1},126 // in the second line127 { testString: "host29.example.com",128 testAttribute: OtherHeader,129 op: Contains,130 customHeader: "X-Spam-Checker-Version",131 count: 1},132 // spans two lines with space133 { testString: "on host29.example.com",134 testAttribute: OtherHeader,135 op: Contains,136 customHeader: "X-Spam-Checker-Version",137 count: 1},138 // subject spanning several lines139 // on the first line140 { testString: "A filter will",141 testAttribute: Subject,142 op: Contains,143 count: 1},144 { testString: "I do not exist",145 testAttribute: Subject,146 op: Contains,147 count: 0},148 // on the second line149 { testString: "this message",150 testAttribute: Subject,151 op: Contains,152 count: 1},153 // spanning second and third line154 { testString: "over many",155 testAttribute: Subject,156 op: Contains,157 count: 1},158 // tests of custom headers db values159 { testString: "a one line header",160 dbHeader: "oneliner"},161 { testString: "a two line header",162 dbHeader: "twoliner"},163 { testString: "a three line header with lotsa space and tabs",164 dbHeader: "threeliner"},165 { testString: "I have no space",166 dbHeader: "nospace"},167 { testString: "too much space",168 dbHeader: "withspace"},169 // tests of custom db headers in a search170 { testString: "one line",171 testAttribute: OtherHeader,172 op: Contains,173 customHeader: "oneliner",174 count: 1},175 { testString: "two line header",176 testAttribute: OtherHeader,177 op: Contains,178 customHeader: "twoliner",179 count: 1},180 { testString: "three line header with lotsa",181 testAttribute: OtherHeader,182 op: Contains,183 customHeader: "threeliner",184 count: 1},185 { testString: "I have no space",186 testAttribute: OtherHeader,187 op: Contains,188 customHeader: "nospace",189 count: 1},190 { testString: "too much space",191 testAttribute: OtherHeader,192 op: Contains,193 customHeader: "withspace",194 count: 1},195];196function run_test()197{198 loadLocalMailAccount();199 var copyListener = 200 {201 OnStartCopy: function() {},202 OnProgress: function(aProgress, aProgressMax) {},203 SetMessageKey: function(aKey) {},204 SetMessageId: function(aMessageId) {},205 OnStopCopy: function(aStatus) { testSearch();}206 };207 // set value of headers we want parsed into the db208 Services.prefs.setCharPref("mailnews.customDBHeaders",209 "oneLiner twoLiner threeLiner noSpace withSpace");210 // Get a message into the local filestore. function testSearch() continues211 // the testing after the copy.212 var bugmail12 = do_get_file("../../../data/bugmail12");213 do_test_pending();214 copyService.CopyFileMessage(bugmail12, gLocalInboxFolder, null, false, 0,215 "", copyListener, null);216}217// process each test from queue, calls itself upon completion of each search218var testObject;219function testSearch()220{221 var test = Tests.shift();222 if (test && test.dbHeader)223 {224 // test of a custom db header225 dump("testing dbHeader " + test.dbHeader + "\n");226 customValue = firstMsgHdr(gLocalInboxFolder).getProperty(test.dbHeader);227 do_check_eq(customValue, test.testString);228 do_timeout(0, testSearch);229 }230 else if (test)231 {232 dump("testing for string '" + test.testString + "'\n");233 testObject = new TestSearch(gLocalInboxFolder,234 test.testString,235 test.testAttribute,236 test.op,237 test.count,238 testSearch,239 null,240 test.customHeader ? test.customHeader : "X-Bugzilla-Watch-Reason");241 }242 else243 {244 testObject = null;245 do_test_finished();246 }...
Using AI Code Generation
1testAttribute('test');2testAttribute('test1');3testAttribute('test2');4testAttribute('test3');5var wpt = require('webpagetest');6var wpt = new WebPageTest('www.webpagetest.org', 'A.3b2e2b9f9e3f3d3e3c3f3c3e3d3e3c3f3c');7testAttribute('test
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 console.log(data);4});5var wpt = require('webpagetest');6var wpt = new WebPageTest('www.webpagetest.org');7 console.log(data);8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org');11 console.log(data);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15 console.log(data);16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org');19 console.log(data);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23 console.log(data);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27 console.log(data);28});29var wpt = require('webpag
Using AI Code Generation
1wpt.testAttribute("testAttribute", "testAttribute");2wpt.testAttribute("testAttribute", "testAttribute");3wpt.testAttribute("testAttribute", "testAttribute");4wpt.testAttribute("testAttribute", "testAttribute");5wpt.testAttribute("testAttribute", "testAttribute");6wpt.testAttribute("testAttribute", "testAttribute");7wpt.testAttribute("testAttribute", "testAttribute");8wpt.testAttribute("testAttribute", "testAttribute");9wpt.testAttribute("testAttribute", "testAttribute");10wpt.testAttribute("testAttribute", "testAttribute");11wpt.testAttribute("testAttribute", "testAttribute");12wpt.testAttribute("testAttribute", "testAttribute");13wpt.testAttribute("testAttribute", "testAttribute");14wpt.testAttribute("testAttribute", "testAttribute");15wpt.testAttribute("testAttribute", "testAttribute");16wpt.testAttribute("testAttribute", "testAttribute");17wpt.testAttribute("testAttribute", "testAttribute");18wpt.testAttribute("testAttribute", "testAttribute");19wpt.testAttribute("testAttribute", "testAttribute
Using AI Code Generation
1wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");2wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");3wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");4wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");5wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");6wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");7wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");8wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");9wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");10wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");11wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");12wptbTest.testAttribute("testAttribute", "testAttribute", "testAttribute", "testAttribute");
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!