简体   繁体   中英

selenium js webdriver.By

I am having an issue with selenium js

I have created my components in json like:

"usernameInputField": {
    "selector": {
      "xpath": "//*[@id='username']"
    }
  }

and I am calling webdriver :

var webdriver = require('selenium-webdriver');

using the data like this:

console.log(webdriver.By.xpath("//*[@id='username']"));

it calls correctly

however when I try to run console.log(webdriver.By(usernameInputField.selector));

I get an error ( TypeError: Class constructors cannot be invoked without 'new' )

what am I doing wrong here?

您可以直接使用常规findElement而不必使用By “类”:

driver.findElement(usernameInputField.selector); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM