How to use getAttributeValue method in Airtest

Best Python code snippet using Airtest

browser_outline.js

Source:browser_outline.js Github

copy

Full Screen

...50 `,51 async (browser, accDoc) => {52 const outline = getNativeInterface(accDoc, "outline");53 is(54 outline.getAttributeValue("AXRole"),55 "AXOutline",56 "Correct role for outline"57 );58 const outChildren = outline.getAttributeValue("AXChildren");59 is(outChildren.length, 2, "Outline has two direct children");60 is(outChildren[0].getAttributeValue("AXSubrole"), "AXOutlineRow");61 is(outChildren[1].getAttributeValue("AXSubrole"), "AXOutlineRow");62 const outRows = outline.getAttributeValue("AXRows");63 is(outRows.length, 4, "Outline has four rows");64 is(65 outRows[0].getAttributeValue("AXDisclosing"),66 0,67 "Row is not disclosing"68 );69 is(70 outRows[0].getAttributeValue("AXDisclosedByRow"),71 null,72 "Row is direct child of outline"73 );74 is(75 outRows[0].getAttributeValue("AXDisclosedRows").length,76 0,77 "Row has no row children, only group"78 );79 is(80 outRows[0].getAttributeValue("AXDisclosureLevel"),81 0,82 "Row is level zero"83 );84 is(outRows[1].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");85 is(86 outRows[1].getAttributeValue("AXDisclosedByRow"),87 null,88 "Row is direct child of group"89 );90 is(91 outRows[1].getAttributeValue("AXDisclosedRows").length,92 0,93 "Row has no row children"94 );95 is(96 outRows[1].getAttributeValue("AXDisclosureLevel"),97 0,98 "Row is level zero"99 );100 is(101 outRows[2].getAttributeValue("AXDisclosing"),102 0,103 "Row is not disclosing"104 );105 is(106 outRows[2].getAttributeValue("AXDisclosedByRow"),107 null,108 "Row is direct child of outline"109 );110 is(111 outRows[2].getAttributeValue("AXDisclosedRows").length,112 1,113 "Row has one row child"114 );115 is(116 outRows[2].getAttributeValue("AXDisclosureLevel"),117 0,118 "Row is level zero"119 );120 is(outRows[3].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");121 is(122 outRows[3]123 .getAttributeValue("AXDisclosedByRow")124 .getAttributeValue("AXDescription"),125 outRows[2].getAttributeValue("AXDescription"),126 "Row is direct child of row[2]"127 );128 is(129 outRows[3].getAttributeValue("AXDisclosedRows").length,130 0,131 "Row has no row children"132 );133 is(134 outRows[3].getAttributeValue("AXDisclosureLevel"),135 1,136 "Row is level one"137 );138 let evt = waitForMacEvent("AXRowExpanded", "vegetables");139 await SpecialPowers.spawn(browser, [], () => {140 content.document141 .getElementById("vegetables")142 .setAttribute("aria-expanded", "true");143 });144 await evt;145 is(146 outRows[2].getAttributeValue("AXDisclosing"),147 1,148 "Row is disclosing after being expanded"149 );150 evt = waitForMacEvent("AXRowCollapsed", "vegetables");151 await SpecialPowers.spawn(browser, [], () => {152 content.document153 .getElementById("vegetables")154 .setAttribute("aria-expanded", "false");155 });156 await evt;157 is(158 outRows[2].getAttributeValue("AXDisclosing"),159 0,160 "Row is not disclosing after being collapsed again"161 );162 }163);164/**165 * Test outline, outline rows with declared properties166 */167addAccessibleTask(168 `169 <h3 id="tree1">170 Foods171 </h3>172 <ul role="tree" aria-labelledby="tree1" id="outline">173 <li role="treeitem"174 aria-level="1"175 aria-setsize="2"176 aria-posinset="1"177 aria-expanded="false">178 <span>179 Fruits180 </span>181 <ul>182 <li role="treeitem"183 aria-level="3"184 aria-setsize="2"185 aria-posinset="1">186 Oranges187 </li>188 <li role="treeitem"189 aria-level="2"190 aria-setsize="2"191 aria-posinset="2"192 aria-expanded="true">193 <span>194 Apples195 </span>196 <ul role="group">197 <li role="treeitem"198 aria-level="3"199 aria-setsize="2"200 aria-posinset="1">201 Honeycrisp202 </li>203 <li role="treeitem"204 aria-level="3"205 aria-setsize="2"206 aria-posinset="2">207 Granny Smith208 </li>209 </ul>210 </li>211 </ul>212 </li>213 <li role="treeitem"214 aria-level="1"215 aria-setsize="2"216 aria-posinset="2"217 aria-expanded="false">218 <span>219 Vegetables220 </span>221 <ul role="group">222 <li role="treeitem"223 aria-level="2"224 aria-setsize="1"225 aria-posinset="1"226 aria-expanded="true">227 <span>228 Podded Vegetables229 </span>230 <ul role="group">231 <li role="treeitem"232 aria-level="3"233 aria-setsize="2"234 aria-posinset="1">235 Lentil236 </li>237 <li role="treeitem"238 aria-level="3"239 aria-setsize="2"240 aria-posinset="2">241 Pea242 </li>243 </ul>244 </li>245 </ul>246 </li>247 </ul>248 `,249 async (browser, accDoc) => {250 const outline = getNativeInterface(accDoc, "outline");251 is(252 outline.getAttributeValue("AXRole"),253 "AXOutline",254 "Correct role for outline"255 );256 const outChildren = outline.getAttributeValue("AXChildren");257 is(outChildren.length, 2, "Outline has two direct children");258 is(outChildren[0].getAttributeValue("AXSubrole"), "AXOutlineRow");259 is(outChildren[1].getAttributeValue("AXSubrole"), "AXOutlineRow");260 const outRows = outline.getAttributeValue("AXRows");261 is(outRows.length, 9, "Outline has nine rows");262 is(263 outRows[0].getAttributeValue("AXDisclosing"),264 0,265 "Row is not disclosing"266 );267 is(268 outRows[0].getAttributeValue("AXDisclosedByRow"),269 null,270 "Row is direct child of outline"271 );272 is(273 outRows[0].getAttributeValue("AXDisclosedRows").length,274 0,275 "Row has no direct row children, has list"276 );277 is(278 outRows[0].getAttributeValue("AXDisclosureLevel"),279 0,280 "Row is level zero"281 );282 is(outRows[2].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");283 is(284 outRows[2].getAttributeValue("AXDisclosedByRow"),285 null,286 "Row is direct child of group"287 );288 is(289 outRows[2].getAttributeValue("AXDisclosedRows").length,290 2,291 "Row has two row children"292 );293 is(294 outRows[2].getAttributeValue("AXDisclosureLevel"),295 1,296 "Row is level one"297 );298 is(299 outRows[3].getAttributeValue("AXDisclosing"),300 0,301 "Row is not disclosing"302 );303 is(304 outRows[3]305 .getAttributeValue("AXDisclosedByRow")306 .getAttributeValue("AXDescription"),307 outRows[2].getAttributeValue("AXDescription"),308 "Row is direct child of row 2"309 );310 is(311 outRows[3].getAttributeValue("AXDisclosedRows").length,312 0,313 "Row has no row children"314 );315 is(316 outRows[3].getAttributeValue("AXDisclosureLevel"),317 2,318 "Row is level two"319 );320 is(321 outRows[5].getAttributeValue("AXDisclosing"),322 0,323 "Row is not disclosing"324 );325 is(326 outRows[5].getAttributeValue("AXDisclosedByRow"),327 null,328 "Row is direct child of outline"329 );330 is(331 outRows[5].getAttributeValue("AXDisclosedRows").length,332 1,333 "Row has no one row child"334 );335 is(336 outRows[5].getAttributeValue("AXDisclosureLevel"),337 0,338 "Row is level zero"339 );340 is(outRows[6].getAttributeValue("AXDisclosing"), 1, "Row is disclosing");341 is(342 outRows[6]343 .getAttributeValue("AXDisclosedByRow")344 .getAttributeValue("AXDescription"),345 outRows[5].getAttributeValue("AXDescription"),346 "Row is direct child of row 5"347 );348 is(349 outRows[6].getAttributeValue("AXDisclosedRows").length,350 2,351 "Row has two row children"352 );353 is(354 outRows[6].getAttributeValue("AXDisclosureLevel"),355 1,356 "Row is level one"357 );358 is(359 outRows[7].getAttributeValue("AXDisclosing"),360 0,361 "Row is not disclosing"362 );363 is(364 outRows[7]365 .getAttributeValue("AXDisclosedByRow")366 .getAttributeValue("AXDescription"),367 outRows[6].getAttributeValue("AXDescription"),368 "Row is direct child of row 6"369 );370 is(371 outRows[7].getAttributeValue("AXDisclosedRows").length,372 0,373 "Row has no row children"374 );375 is(376 outRows[7].getAttributeValue("AXDisclosureLevel"),377 2,378 "Row is level two"379 );380 }381);382// Test outline that isn't built with li/uls gets correct desc383addAccessibleTask(384 `385 <div role="tree" id="tree" tabindex="0" aria-label="My drive" aria-activedescendant="myfiles">386 <div id="myfiles" role="treeitem" aria-label="My files" aria-selected="true" aria-expanded="false">My files</div>387 <div role="treeitem" aria-label="Shared items" aria-selected="false" aria-expanded="false">Shared items</div>388 </div>389 `,390 async (browser, accDoc) => {391 const tree = getNativeInterface(accDoc, "tree");392 is(tree.getAttributeValue("AXRole"), "AXOutline", "Correct role for tree");393 const treeItems = tree.getAttributeValue("AXChildren");394 is(treeItems.length, 2, "Outline has two direct children");395 is(treeItems[0].getAttributeValue("AXSubrole"), "AXOutlineRow");396 is(treeItems[1].getAttributeValue("AXSubrole"), "AXOutlineRow");397 const outRows = tree.getAttributeValue("AXRows");398 is(outRows.length, 2, "Outline has two rows");399 is(400 outRows[0].getAttributeValue("AXDescription"),401 "My files",402 "files labelled correctly"403 );404 is(405 outRows[1].getAttributeValue("AXDescription"),406 "Shared items",407 "shared items labelled correctly"408 );409 }410);411// Test outline registers AXDisclosed attr as settable412addAccessibleTask(413 `414 <div role="tree" id="tree" tabindex="0" aria-label="My drive" aria-activedescendant="myfiles">415 <div id="myfiles" role="treeitem" aria-label="My files" aria-selected="true" aria-expanded="false">My files</div>416 <div role="treeitem" aria-label="Shared items" aria-selected="false" aria-expanded="true">Shared items</div>417 </div>418 `,419 async (browser, accDoc) => {420 const tree = getNativeInterface(accDoc, "tree");421 const treeItems = tree.getAttributeValue("AXChildren");422 is(treeItems.length, 2, "Outline has two direct children");423 is(treeItems[0].getAttributeValue("AXDisclosing"), 0);424 is(treeItems[1].getAttributeValue("AXDisclosing"), 1);425 is(treeItems[0].isAttributeSettable("AXDisclosing"), true);426 is(treeItems[1].isAttributeSettable("AXDisclosing"), true);427 // attempt to change attribute values428 treeItems[0].setAttributeValue("AXDisclosing", 1);429 treeItems[0].setAttributeValue("AXDisclosing", 0);430 // verify they're unchanged431 is(treeItems[0].getAttributeValue("AXDisclosing"), 0);432 is(treeItems[1].getAttributeValue("AXDisclosing"), 1);433 }434);435// Test outline rows correctly expose checkable, checked/unchecked/mixed status436addAccessibleTask(437 `438 <div role="tree" id="tree">439 <div role="treeitem" aria-checked="false" id="l1">440 Leaf 1441 </div>442 <div role="treeitem" aria-checked="true" id="l2">443 Leaf 2444 </div>445 <div role="treeitem" id="l3">446 Leaf 3447 </div>448 <div role="treeitem" aria-checked="mixed" id="l4">449 Leaf 4450 </div>451 </div>452 `,453 async (browser, accDoc) => {454 const tree = getNativeInterface(accDoc, "tree");455 const treeItems = tree.getAttributeValue("AXChildren");456 is(treeItems.length, 4, "Outline has four direct children");457 is(458 treeItems[0].getAttributeValue("AXValue"),459 0,460 "Child one is not checked"461 );462 is(treeItems[1].getAttributeValue("AXValue"), 1, "Child two is checked");463 is(464 treeItems[2].getAttributeValue("AXValue"),465 null,466 "Child three is not checkable and has no val"467 );468 is(treeItems[3].getAttributeValue("AXValue"), 2, "Child four is mixed");469 let stateChanged = Promise.all([470 waitForMacEvent("AXValueChanged", "l1"),471 waitForStateChange("l1", STATE_CHECKED, true),472 ]);473 // We should get a state change event for checked.474 await SpecialPowers.spawn(browser, [], () => {475 content.document476 .getElementById("l1")477 .setAttribute("aria-checked", "true");478 });479 await stateChanged;480 is(treeItems[0].getAttributeValue("AXValue"), 1, "Child one is checked");481 stateChanged = Promise.all([482 waitForMacEvent("AXValueChanged", "l2"),483 waitForMacEvent("AXValueChanged", "l2"),484 waitForStateChange("l2", STATE_CHECKED, false),485 waitForStateChange("l2", STATE_CHECKABLE, false),486 ]);487 // We should get a state change event for both checked and checkable,488 // and value changes for both.489 await SpecialPowers.spawn(browser, [], () => {490 content.document.getElementById("l2").removeAttribute("aria-checked");491 });492 await stateChanged;493 is(494 treeItems[1].getAttributeValue("AXValue"),495 null,496 "Child two is not checkable and has no val"497 );498 stateChanged = Promise.all([499 waitForMacEvent("AXValueChanged", "l3"),500 waitForMacEvent("AXValueChanged", "l3"),501 waitForStateChange("l3", STATE_CHECKED, true),502 waitForStateChange("l3", STATE_CHECKABLE, true),503 ]);504 // We should get a state change event for both checked and checkable,505 // and value changes for each.506 await SpecialPowers.spawn(browser, [], () => {507 content.document508 .getElementById("l3")509 .setAttribute("aria-checked", "true");510 });511 await stateChanged;512 is(treeItems[2].getAttributeValue("AXValue"), 1, "Child three is checked");513 stateChanged = Promise.all([514 waitForMacEvent("AXValueChanged", "l4"),515 waitForMacEvent("AXValueChanged", "l4"),516 waitForStateChange("l4", STATE_MIXED, false),517 waitForStateChange("l4", STATE_CHECKABLE, false),518 ]);519 // We should get a state change event for both mixed and checkable,520 // and value changes for each.521 await SpecialPowers.spawn(browser, [], () => {522 content.document.getElementById("l4").removeAttribute("aria-checked");523 });524 await stateChanged;525 is(526 treeItems[3].getAttributeValue("AXValue"),527 null,528 "Child four is not checkable and has no value"529 );530 }...

Full Screen

Full Screen

browser_outline_xul.js

Source:browser_outline_xul.js Github

copy

Full Screen

...8 "mac/doc_tree.xhtml",9 async (browser, accDoc) => {10 const tree = getNativeInterface(accDoc, "tree");11 is(12 tree.getAttributeValue("AXRole"),13 "AXOutline",14 "Found tree with role outline"15 );16 // XUL trees store all rows as direct children of the outline,17 // so we should see nine here instead of just three:18 // (Groceries, Fruits, Veggies)19 const treeChildren = tree.getAttributeValue("AXChildren");20 is(treeChildren.length, 9, "Found nine direct children");21 const treeCols = tree.getAttributeValue("AXColumns");22 is(treeCols.length, 1, "Found one column in tree");23 // Here, we should get only outline rows, not the title24 const treeRows = tree.getAttributeValue("AXRows");25 is(treeRows.length, 8, "Found 8 total rows");26 is(27 treeRows[0].getAttributeValue("AXDescription"),28 "Fruits",29 "Located correct first row, row has correct desc"30 );31 is(32 treeRows[0].getAttributeValue("AXDisclosing"),33 1,34 "Fruits is disclosing"35 );36 is(37 treeRows[0].getAttributeValue("AXDisclosedByRow"),38 null,39 "Fruits is disclosed by outline"40 );41 is(42 treeRows[0].getAttributeValue("AXDisclosureLevel"),43 0,44 "Fruits is level zero"45 );46 let disclosedRows = treeRows[0].getAttributeValue("AXDisclosedRows");47 is(disclosedRows.length, 2, "Fruits discloses two rows");48 is(49 disclosedRows[0].getAttributeValue("AXDescription"),50 "Apple",51 "fruits discloses apple"52 );53 is(54 disclosedRows[1].getAttributeValue("AXDescription"),55 "Orange",56 "fruits discloses orange"57 );58 is(59 treeRows[1].getAttributeValue("AXDescription"),60 "Apple",61 "Located correct second row, row has correct desc"62 );63 is(64 treeRows[1].getAttributeValue("AXDisclosing"),65 0,66 "Apple is not disclosing"67 );68 is(69 treeRows[1]70 .getAttributeValue("AXDisclosedByRow")71 .getAttributeValue("AXDescription"),72 "Fruits",73 "Apple is disclosed by fruits"74 );75 is(76 treeRows[1].getAttributeValue("AXDisclosureLevel"),77 1,78 "Apple is level one"79 );80 is(81 treeRows[1].getAttributeValue("AXDisclosedRows").length,82 0,83 "Apple does not disclose rows"84 );85 is(86 treeRows[2].getAttributeValue("AXDescription"),87 "Orange",88 "Located correct third row, row has correct desc"89 );90 is(91 treeRows[2].getAttributeValue("AXDisclosing"),92 0,93 "Orange is not disclosing"94 );95 is(96 treeRows[2]97 .getAttributeValue("AXDisclosedByRow")98 .getAttributeValue("AXDescription"),99 "Fruits",100 "Orange is disclosed by fruits"101 );102 is(103 treeRows[2].getAttributeValue("AXDisclosureLevel"),104 1,105 "Orange is level one"106 );107 is(108 treeRows[2].getAttributeValue("AXDisclosedRows").length,109 0,110 "Orange does not disclose rows"111 );112 is(113 treeRows[3].getAttributeValue("AXDescription"),114 "Veggies",115 "Located correct fourth row, row has correct desc"116 );117 is(118 treeRows[3].getAttributeValue("AXDisclosing"),119 1,120 "Veggies is disclosing"121 );122 is(123 treeRows[3].getAttributeValue("AXDisclosedByRow"),124 null,125 "Veggies is disclosed by outline"126 );127 is(128 treeRows[3].getAttributeValue("AXDisclosureLevel"),129 0,130 "Veggies is level zero"131 );132 disclosedRows = treeRows[3].getAttributeValue("AXDisclosedRows");133 is(disclosedRows.length, 2, "Veggies discloses two rows");134 is(135 disclosedRows[0].getAttributeValue("AXDescription"),136 "Green Veggies",137 "Veggies discloses green veggies"138 );139 is(140 disclosedRows[1].getAttributeValue("AXDescription"),141 "Squash",142 "Veggies discloses squash"143 );144 is(145 treeRows[4].getAttributeValue("AXDescription"),146 "Green Veggies",147 "Located correct fifth row, row has correct desc"148 );149 is(150 treeRows[4].getAttributeValue("AXDisclosing"),151 1,152 "Green veggies is disclosing"153 );154 is(155 treeRows[4]156 .getAttributeValue("AXDisclosedByRow")157 .getAttributeValue("AXDescription"),158 "Veggies",159 "Green Veggies is disclosed by veggies"160 );161 is(162 treeRows[4].getAttributeValue("AXDisclosureLevel"),163 1,164 "Green veggies is level one"165 );166 disclosedRows = treeRows[4].getAttributeValue("AXDisclosedRows");167 is(disclosedRows.length, 2, "Green veggies has two rows");168 is(169 disclosedRows[0].getAttributeValue("AXDescription"),170 "Spinach",171 "Green veggies discloses spinach"172 );173 is(174 disclosedRows[1].getAttributeValue("AXDescription"),175 "Peas",176 "Green veggies discloses peas"177 );178 is(179 treeRows[5].getAttributeValue("AXDescription"),180 "Spinach",181 "Located correct sixth row, row has correct desc"182 );183 is(184 treeRows[5].getAttributeValue("AXDisclosing"),185 0,186 "Spinach is not disclosing"187 );188 is(189 treeRows[5]190 .getAttributeValue("AXDisclosedByRow")191 .getAttributeValue("AXDescription"),192 "Green Veggies",193 "Spinach is disclosed by green veggies"194 );195 is(196 treeRows[5].getAttributeValue("AXDisclosureLevel"),197 2,198 "Spinach is level two"199 );200 is(201 treeRows[5].getAttributeValue("AXDisclosedRows").length,202 0,203 "Spinach does not disclose rows"204 );205 is(206 treeRows[6].getAttributeValue("AXDescription"),207 "Peas",208 "Located correct seventh row, row has correct desc"209 );210 is(211 treeRows[6].getAttributeValue("AXDisclosing"),212 0,213 "Peas is not disclosing"214 );215 is(216 treeRows[6]217 .getAttributeValue("AXDisclosedByRow")218 .getAttributeValue("AXDescription"),219 "Green Veggies",220 "Peas is disclosed by green veggies"221 );222 is(223 treeRows[6].getAttributeValue("AXDisclosureLevel"),224 2,225 "Peas is level two"226 );227 is(228 treeRows[6].getAttributeValue("AXDisclosedRows").length,229 0,230 "Peas does not disclose rows"231 );232 is(233 treeRows[7].getAttributeValue("AXDescription"),234 "Squash",235 "Located correct eighth row, row has correct desc"236 );237 is(238 treeRows[7].getAttributeValue("AXDisclosing"),239 0,240 "Squash is not disclosing"241 );242 is(243 treeRows[7]244 .getAttributeValue("AXDisclosedByRow")245 .getAttributeValue("AXDescription"),246 "Veggies",247 "Squash is disclosed by veggies"248 );249 is(250 treeRows[7].getAttributeValue("AXDisclosureLevel"),251 1,252 "Squash is level one"253 );254 is(255 treeRows[7].getAttributeValue("AXDisclosedRows").length,256 0,257 "Squash does not disclose rows"258 );259 },260 { topLevel: false, chrome: true }...

Full Screen

Full Screen

call.py

Source:call.py Github

copy

Full Screen

...73 reject = node.getChild("reject")74 terminate = node.getChild("terminate")75 if offer:76 _type = "offer"77 callId = offer.getAttributeValue("call-id")78 elif transport:79 _type = "transport"80 callId = transport.getAttributeValue("call-id")81 elif relaylatency:82 _type = "relaylatency"83 callId = relaylatency.getAttributeValue("call-id")84 elif reject:85 _type = "reject"86 callId = reject.getAttributeValue("call-id")87 elif terminate:88 _type = "terminate"89 callId = terminate.getAttributeValue("call-id")90 return CallProtocolEntity(91 node.getAttributeValue("id"),92 _type,93 node.getAttributeValue("t"),94 node.getAttributeValue("notify"),95 node.getAttributeValue("offline"),96 node.getAttributeValue("retry"),97 node.getAttributeValue("e"),98 callId,99 node.getAttributeValue("from"),100 node.getAttributeValue("to")...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest 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