Skip to content

Commit 4d34ead

Browse files
author
Feroz Khan
committed
Fixed failing unit tests
1 parent 49495db commit 4d34ead

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/commands/element.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ export async function findElOrEls(
3333
? JSON.parse(selector)
3434
: selector; // Special case
3535

36-
// Use strategy/selector format for Flutter locators and Android driver
37-
if (isFlutterLocator || proxyDriver instanceof AndroidUiautomator2Driver || proxyDriver instanceof XCUITestDriver) {
38-
return { strategy, selector: parsedSelector, context };
39-
} else {
40-
// Use using/value format for all other cases
36+
// If user is looking for Native IOS/Mac locator
37+
if (
38+
!isFlutterLocator &&
39+
(proxyDriver instanceof XCUITestDriver ||
40+
proxyDriver instanceof Mac2Driver)
41+
) {
4142
return { using: strategy, value: parsedSelector, context };
43+
} else {
44+
return { strategy, selector: parsedSelector, context };
4245
}
4346
}
4447

test/unit/element.specs.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ describe('Element Interaction Functions', () => {
7272
expect(ELEMENT_CACHE.get('elem1')).to.equal(mockDriver);
7373
expect(
7474
mockDriver.command.calledWith('/element', 'POST', {
75-
using: 'strategy',
76-
value: 'selector',
75+
strategy: 'strategy',
76+
selector: 'selector',
7777
context: 'context',
7878
}),
7979
).to.be.true;
@@ -100,8 +100,8 @@ describe('Element Interaction Functions', () => {
100100
expect(ELEMENT_CACHE.get('elem2')).to.equal(mockDriver);
101101
expect(
102102
mockDriver.command.calledWith('/elements', 'POST', {
103-
using: 'strategy',
104-
value: 'selector',
103+
strategy: 'strategy',
104+
selector: 'selector',
105105
context: 'context',
106106
}),
107107
).to.be.true;
@@ -155,8 +155,8 @@ describe('Element Interaction Functions', () => {
155155

156156
expect(
157157
mockDriver.command.calledWith('/element', 'POST', {
158-
strategy: 'strategy',
159-
selector: 'selector',
158+
using: 'strategy',
159+
value: 'selector',
160160
context: 'context',
161161
}),
162162
).to.be.true;
@@ -203,8 +203,8 @@ describe('Element Interaction Functions', () => {
203203
expect(ELEMENT_CACHE.get('elem1')).to.equal(mockDriver);
204204
expect(
205205
mockDriver.command.calledWith('/element', 'POST', {
206-
using: 'strategy',
207-
value: 'selector',
206+
strategy: 'strategy',
207+
selector: 'selector',
208208
context: 'context',
209209
}),
210210
).to.be.true;

0 commit comments

Comments
 (0)