1.0.32 • Published 3 years ago

xpath-converter v1.0.32

Weekly downloads
28
License
ISC
Repository
-
Last release
3 years ago

Purpose

This is a converter that can convert location words to XPath.

Installation

$ npm i xpath-converter --save

Usage

1. Create your own page class to extend Locator, and add your location type as parameter:
    const xpathConverter = require('xpath-converter');
    
    class CustomPage extends xpathConverter.adapter.Locator {
      super() {
      }
    
      'page'({ name, type, index }) { return `header[h6="${name}"]["${index}"]`; }
      
      'section'({ name, type, index }) { return `setion[h2="${name}"]["${index}"]`; }
      
      'input'({ name, type, index }) { return `label[text()="${name}"]/following/::input["${index}"]`; }

      execute(type) {
        const locator = new MainPage();
        return locator[type] && locator[type](...[].slice.call(arguments, 1));
      }
    }

2. Call the function createElement with your own class:
    var pageClass = require('./CustomPage');
    var element = new xpathConverter.adapter.Element();
    var xpath = element.createElement(name, type, moreInfo, pageClass);
    

Words introduce

There are four parts in a part of locator words.

direction: in, behind, in-front-of, in-child-of (Do not need to add it at beginning) order: 1st, 2nd, 3rd, 16th ... (Put 'the' for default) location type: id, input, checkbox ... (This is defined in your own page class) name: "customer name", "number" ... (The text in your page)

e.g 1st input "Customer Name" in 3rd section "Customer Information" behind the page "Customer" Xpath output: //headerh6="Customer"/following::setionh2="Customer Information"/descendant::labeltext()="Customer Name"/following/::input"1"

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago