-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added isVisible Missing Command (Fixes #4037) #4065
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Returns the visible text for the element. | ||
* | ||
* For more info on working with DOM elements in Nightwatch, refer to the <a href="https://nightwatchjs.org/guide/writing-tests/finding-interacting-with-dom-elements.html">Finding & interacting with DOM Elements</a> guide page. | ||
* | ||
* @example | ||
* export default { | ||
* demoTest(browser: NightwatchAPI): void { | ||
* const result = browser.element('#main ul li a.first').isVisible(); | ||
* .assert.valueEquals('custom text'); | ||
* }, | ||
* | ||
* async demoTestAsync(browser: NightwatchAPI): Promise<void> { | ||
* const result = await browser.element('#main ul li a.first').isVisible(); | ||
* console.log('element text:', result); | ||
* } | ||
* } | ||
* | ||
* @since 3.0.0 | ||
* @method isVisible | ||
* @memberof ScopedWebElement | ||
* @instance | ||
* @syntax browser.element(selector).isVisible() | ||
* @see https://www.w3.org/TR/webdriver#dfn-get-element-text | ||
* @returns {ScopedValue<string>} | ||
* @alias isDisplayed | ||
Comment on lines
+19
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be updated as well. |
||
*/ | ||
module.exports.command = function() { | ||
return this.runQueuedCommandScoped('isVisibleElement'); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -546,7 +546,12 @@ module.exports = class MethodMappings { | |
|
||
return elementText; | ||
}, | ||
async isVisibleElement(id) { | ||
const element = await this.getWebElement(id); | ||
const elementVisible = await element.isDisplayed(); | ||
|
||
return elementVisible; | ||
}, | ||
Comment on lines
+549
to
+554
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to create this again, there's already a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh i didnt notice isElementDisplayed because i was taking reference from getText() |
||
// the value param is compulsory | ||
async getElementValue(webElementOrId, value) { | ||
const element = this.getWebElement(webElementOrId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're adding some example to JSDoc or anywhere else, it should be tested by you first by running them in one of the example test files. This example code won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alrighty ill take care of this in future