Skip to content

Commit

Permalink
Refactored code: formatting improvements and deleted alias in jsDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayush-Vish committed Apr 17, 2024
1 parent 56608ec commit 6ede6b9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 43 deletions.
2 changes: 0 additions & 2 deletions lib/api/web-element/commands/getProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
* @syntax browser.element(selector).getProperty(name)
* @see https://www.w3.org/TR/webdriver#get-element-property
* @returns {ScopedValue<string>}
* @alias prop
* @alias property
*/
module.exports.command = function(name) {
return this.runQueuedCommandScoped('getElementProperty', name);
Expand Down
54 changes: 15 additions & 39 deletions test/src/api/commands/web-element/testGetProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,7 @@ describe('element().getProperty() command', function () {
assert.deepStrictEqual(resultValue, ['.signup']);
});

it('test .element().find().getProperty()', async function() {
MockServer.addMock({
url: '/session/13521-10219-202/element/1/property/classList',
method: 'GET',
response: JSON.stringify({
value: ['.btn']
})
}, true);

const resultPromise = this.client.api.element('#signupSection').find('#helpBtn').getProperty('classList');
assert.strictEqual(resultPromise instanceof Element, false);
assert.strictEqual(typeof resultPromise.find, 'undefined');

assert.strictEqual(resultPromise instanceof Promise, false);
assert.strictEqual(typeof resultPromise.then, 'function');

const result = await resultPromise;
assert.strictEqual(result instanceof WebElement, false);
assert.deepStrictEqual(result, ['.btn']);

const resultValue = await resultPromise.value;
assert.deepStrictEqual(resultValue, ['.btn']);
});

it('test .element.find().getProperty()', async function() {
it('test .element.find().prop()', async function() {
MockServer.addMock({
url: '/session/13521-10219-202/element/0/property/classList',
method: 'GET',
Expand All @@ -95,7 +71,7 @@ describe('element().getProperty() command', function () {
})
}, true);

const resultPromise = this.client.api.element.find('#signupSection').getProperty('classList');
const resultPromise = this.client.api.element.find('#signupSection').prop('classList');
assert.strictEqual(resultPromise instanceof Element, false);
assert.strictEqual(typeof resultPromise.find, 'undefined');

Expand All @@ -109,17 +85,17 @@ describe('element().getProperty() command', function () {
const resultValue = await resultPromise.value;
assert.deepStrictEqual(resultValue, ['.signup']);
});

it('test .element.find().prop()', async function() {
it('test .element().find().getProperty()', async function() {
MockServer.addMock({
url: '/session/13521-10219-202/element/0/property/classList',
url: '/session/13521-10219-202/element/1/property/classList',
method: 'GET',
response: JSON.stringify({
value: ['.signup']
value: ['.btn']
})
}, true);

const resultPromise = this.client.api.element.find('#signupSection').prop('classList');
const resultPromise = this.client.api.element('#signupSection').find('#helpBtn').getProperty('classList');
assert.strictEqual(resultPromise instanceof Element, false);
assert.strictEqual(typeof resultPromise.find, 'undefined');

Expand All @@ -128,22 +104,22 @@ describe('element().getProperty() command', function () {

const result = await resultPromise;
assert.strictEqual(result instanceof WebElement, false);
assert.deepStrictEqual(result, ['.signup']);
assert.deepStrictEqual(result, ['.btn']);

const resultValue = await resultPromise.value;
assert.deepStrictEqual(resultValue, ['.signup']);
assert.deepStrictEqual(resultValue, ['.btn']);
});

it('test .element().find().property()', async function(){
it('test .element.find().getProperty()', async function() {
MockServer.addMock({
url: '/session/13521-10219-202/element/1/property/classList',
url: '/session/13521-10219-202/element/0/property/classList',
method: 'GET',
response: JSON.stringify({
value: ['.btn']
value: ['.signup']
})
}, true);

const resultPromise = this.client.api.element('#signupSection').find('#helpBtn').property('classList');
const resultPromise = this.client.api.element.find('#signupSection').getProperty('classList');
assert.strictEqual(resultPromise instanceof Element, false);
assert.strictEqual(typeof resultPromise.find, 'undefined');

Expand All @@ -152,10 +128,10 @@ describe('element().getProperty() command', function () {

const result = await resultPromise;
assert.strictEqual(result instanceof WebElement, false);
assert.deepStrictEqual(result, ['.btn']);
assert.deepStrictEqual(result, ['.signup']);

const resultValue = await resultPromise.value;
assert.deepStrictEqual(resultValue, ['.btn']);
assert.deepStrictEqual(resultValue, ['.signup']);
});

});
2 changes: 0 additions & 2 deletions types/web-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ export interface ScopedElement extends Element, PromiseLike<WebElement> {
submit(): Promise<WebElement>;

getProperty(name: string): ElementValue<string | null>;

prop(name: string): ElementValue<string | null>;

property(name: string): ElementValue<string | null>;

setProperty(name: string, value: unknown): Promise<WebElement>;
Expand Down

0 comments on commit 6ede6b9

Please sign in to comment.