Skip to content

Commit

Permalink
Fix element api support in POM. (#3689)
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Apr 12, 2023
1 parent f258cf6 commit 3901dca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/api/web-element/element-locator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {By, RelativeBy} = require('selenium-webdriver');
const Utils = require('../../utils');
const Element = require('../../element/index.js');
const Locator = require('../../element/locator.js');
const NightwatchLocator = require('../../element/locator-factory');

class ElementLocator {
constructor(selector, options = {}) {
Expand Down Expand Up @@ -74,10 +75,14 @@ class ElementLocator {
static getCondition(element, strategy) {
const locateStrategy = ElementLocator.getLocateStrategy(element, strategy);

if (element instanceof By || element instanceof RelativeBy || element instanceof Element) {
if (element instanceof By || element instanceof RelativeBy) {
return element;
}

if (element instanceof Element) {
return NightwatchLocator.create(element);
}

if (!ElementLocator.isElementDescriptor(element)) {
return By[Locator.AVAILABLE_LOCATORS[locateStrategy]](element);
}
Expand Down

0 comments on commit 3901dca

Please sign in to comment.