Skip to content

Commit acdf3f5

Browse files
committed
export implicit xpath
1 parent 9de0f43 commit acdf3f5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/selianize/__tests__/location.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ describe("location code emitter", () => {
5454
const selector = "someXpath";
5555
return expect(LocationEmitter.emit(`${type}=${selector}`)).resolves.toBe(`By.xpath("${selector}")`);
5656
});
57+
it("should emit implicit xpath locator", () => {
58+
const selector = "//test=xpath";
59+
return expect(LocationEmitter.emit(selector)).resolves.toBe(`By.xpath("${selector}")`);
60+
});
5761
it("should emit name locator", () => {
5862
const type = "name";
5963
const selector = "someName";

packages/selianize/src/location.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const emitters = {
2727

2828
export function emit(location) {
2929
return new Promise(async (res, rej) => {
30+
if (/^\/\//.test(location)) {
31+
return res(await emitters.xpath(location));
32+
}
3033
const fragments = location.split("=");
3134
const type = fragments.shift();
3235
const selector = StringEscape(fragments.join("="));

0 commit comments

Comments
 (0)