Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Quality Assurance Introduction to Selenium Automation Nation Sub Pages are Pages, Too!

Shane Moulton
Shane Moulton
10,538 Points

Arrow Function not working throwing back unable to locate errors

const By = require("selenium-webdriver").By;

class HomePage {
    constructor(driver){
        this.driver = driver;
        this.locators = {
            inviteeForm: By.id("registrar"),
            inviteeNameField: By.css("#registrar input[name='name']"),
            toogleVisibility: By.css(".main > div input"),
            inviteeByName: name => By.xpath(`//span[text() = "${name}"]/..`)
        };
    }
    open(){
        this.driver.get(process.env.URL);
    }

    addInvitee(name) {
        this.driver.findElement(this.locators.inviteeNameField).sendKeys(name);
         this.driver.findElement(this.locators.inviteeForm).submit();
}

 toogleVisibility(){
    this.driver.findElement(this.locators.toogleVisibility).click();
}

findInviteeByName(name){
    const el = this.driver.findElement(this.locators.inviteeByName(name));
        return new Invitee(el);
 }
}

class Invitee{
    constructor(element){
        this.element = element;
        this.locators = {
            removeButton: By.css('button:last-child'),
            confirmedCheckbox: By.css("input[type='checkbox']")
        };
    }
    remove(){
        this.element.findElement(this.locators.removeButton).click();
    }

    toggleConfirmation(){
        this.element.findElement(this.locators.confirmedCheckbox).click();
    }
}

module.exports = HomePage
node:939) UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element: {"method"
:"xpath","selector":"//span[text() = "David Riesz"]/.."}  (Session info: chrome=66.0.3359.181)
  (Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.11.6 x86_64)
    at Object.checkLegacyResponse (/Users/shanemoulton/selenium-basics/node_modules/selenium-webdriver/lib/error.js:5
85:15)
    at parseHttpResponse (/Users/shanemoulton/selenium-basics/node_modules/selenium-webdriver/lib/http.js:533:13)
    at Executor.execute (/Users/shanemoulton/selenium-basics/node_modules/selenium-webdriver/lib/http.js:468:26)    at <anonymous>    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:939) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (reje
ction id: 1)
(node:939) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejectio
ns that are not handled will terminate the Node.js process with a non-zero exit code.(node:939) UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element: {"method"
:"xpath","selector":"//span[text() = "Jennifer Nordell"]/.."}
  (Session info: chrome=66.0.3359.181)
  (Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.11.6 x86_64)
    at Object.checkLegacyResponse (/Users/shanemoulton/selenium-basics/node_modules/selenium-webdriver/lib/error.js:5
85:15)    at parseHttpResponse (/Users/shanemoulton/selenium-basics/node_modules/selenium-webdriver/lib/http.js:533:13)    at Executor.execute (/Users/shanemoulton/selenium-basics/node_modules/selenium-webdriver/lib/http.js:468:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)(node:939) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing in
side of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (reje
ction id: 2)

Moderator edited: Markdown added so that code renders properly in the forums. -jn

Same error here.

Dylan Meares
Dylan Meares
6,323 Points

I'm having the same issue described here. Is there setup missing? Is the test website broken?