1.0.32 • Published 2 years ago

xpath-converter v1.0.32

Weekly downloads
28
License
ISC
Repository
-
Last release
2 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

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.26

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago