Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class WebDriver extends Helper {
const res = await this._locate(locator, true);
assertElementExists(res, locator);

return forEachAsync(res, async el => this.browser.getElementAttribute(getElementId(el), 'value'));
return forEachAsync(res, async el => el.getValue());
}

/**
Expand All @@ -814,7 +814,7 @@ class WebDriver extends Helper {
async grabAttributeFrom(locator, attr) {
const res = await this._locate(locator, true);
assertElementExists(res, locator);
return forEachAsync(res, async el => this.browser.getElementAttribute(getElementId(el), attr));
return forEachAsync(res, async el => el.getAttribute(attr));
}

/**
Expand Down Expand Up @@ -1116,7 +1116,7 @@ class WebDriver extends Helper {
const elemAmount = res.length;

let attrs = await forEachAsync(res, async (el) => {
return forEachAsync(Object.keys(attributes), async attr => this.browser.getElementAttribute(getElementId(el), attr));
return forEachAsync(Object.keys(attributes), async attr => el.getAttribute(attr));
});

const values = Object.keys(attributes).map(key => attributes[key]);
Expand Down Expand Up @@ -1628,7 +1628,7 @@ class WebDriver extends Helper {
async () => {
const res = await findFields.call(this, field);
if (!res || res.length === 0) return false;
const selected = await forEachAsync(res, async el => this.browser.getElementAttribute(getElementId(el), 'value'));
const selected = await forEachAsync(res, async el => el.getValue());
if (Array.isArray(selected)) {
return selected.filter(part => part.indexOf(value) >= 0).length > 0;
}
Expand Down Expand Up @@ -2057,7 +2057,8 @@ async function proceedSeeField(assertType, field, value) {

const proceedMultiple = async (fields) => {
const fieldResults = toArray(await forEachAsync(fields, async (el) => {
return this.browser.getElementAttribute(getElementId(el), 'value');
const elementId = getElementId(el);
return this.browser.isW3C ? el.getValue() : this.browser.getElementAttribute(elementId, 'value');
}));

if (typeof value === 'boolean') {
Expand All @@ -2076,13 +2077,13 @@ async function proceedSeeField(assertType, field, value) {
const filterSelectedByValue = async (elements, value) => {
return filterAsync(elements, async (el) => {
const elementId = getElementId(el);
const currentValue = await this.browser.getElementAttribute(elementId, 'value');
const currentValue = this.browser.isW3C ? await el.getValue() : await this.browser.getElementAttribute(elementId, 'value');
const isSelected = await this.browser.isElementSelected(elementId);
return currentValue === value && isSelected;
});
};

const tag = await this.browser.getElementTagName(elemId);
const tag = await elem.getTagName();
if (tag === 'select') {
const subOptions = await this.browser.findElementsFromElement(elemId, 'css', 'option');

Expand All @@ -2097,7 +2098,7 @@ async function proceedSeeField(assertType, field, value) {
}

if (tag === 'input') {
const fieldType = await this.browser.getElementAttribute(elemId, 'type');
const fieldType = await elem.getAttribute('type');

if (fieldType === 'checkbox' || fieldType === 'radio') {
if (typeof value === 'boolean') {
Expand Down