mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
Dactyloidae iOS initial commit
This commit is contained in:
parent
daa6179d22
commit
7154a0497e
2123 changed files with 197052 additions and 0 deletions
60
mobile/ios/UITests/KIFHelper.js
Normal file
60
mobile/ios/UITests/KIFHelper.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
var KIFHelper = {
|
||||
/**
|
||||
* Determines whether an element with the given accessibility label exists.
|
||||
* @return True if an element was found
|
||||
*/
|
||||
hasElementWithAccessibilityLabel: function (value) {
|
||||
return this._getElementWithAccessibilityLabel(document.body, value) !== null;
|
||||
},
|
||||
|
||||
_getElementWithAccessibilityLabel: function (el, value) {
|
||||
if (el.textContent == value || el.title == value || el.value == value) {
|
||||
return el;
|
||||
}
|
||||
|
||||
for (var i = 0; i < el.children.length; i++) {
|
||||
var found = this._getElementWithAccessibilityLabel(el.children[i], value);
|
||||
if (found) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the text for an input element with the given name.
|
||||
* @return True if successful
|
||||
*/
|
||||
enterTextIntoInputWithName: function (text, name) {
|
||||
var inputs = document.getElementsByName(name);
|
||||
if (inputs.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var input = inputs[0];
|
||||
if (input.tagName !== "INPUT") {
|
||||
return false;
|
||||
}
|
||||
|
||||
input.value = text;
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Taps an element with the given accessibility label.
|
||||
* @return True if successful
|
||||
*/
|
||||
tapElementWithAccessibilityLabel: function (label) {
|
||||
var found = this._getElementWithAccessibilityLabel(document.body, label);
|
||||
if (found) {
|
||||
found.click();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue