I'm using NodeJS, Mocha & Selenium to automate filling my timesheet and I'm facing issue in waiting for the login form.
The URL "https://timesheet.mydomain.com/timesheet.aspx" will open redirect to the login page of my company and I need to wait until the login inputs are visible.
The username text box can be identified by the id - userid and i've added the below line to wait for it's visibility. However, it fails to wait and showing the following error.
How do i fix this ? I've tried to get solutions for this in already answered questions in Stackoverflow and other forums, but couldn't get any. Please help to fix this.
Protractor Async/Await Error: Unhandled promise rejection
const { Builder, By, Key, until } = require('selenium-webdriver')
const assert = require('assert')
describe('Timesheet', function() {
this.timeout(30000)
let driver
let vars
beforeEach(async function() {
driver = await new Builder().forBrowser('chrome').build()
vars = {}
})
afterEach(async function() {
await driver.quit();
})
it('Timesheet', async function() {
await driver.get("https://timesheet.mydomain.com/timesheet.aspx")
await driver.manage().window().setRect(1920, 1053)
await driver.wait(until.elementIsVisible(await driver.findElement(By.id("userid"))), 60000)
await driver.findElement(By.id("userid")).sendKeys("userid@mydomain.com")
await driver.findElement(By.id("userid")).sendKeys(Key.ENTER)
})
})
./node_modules/.bin/mocha timeSheet.js
Timesheet:
NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"*[id="userid"]"}
(Session info: chrome=83.0.4103.116)
at Object.throwDecodedError (node_modules/selenium-webdriver/lib/error.js:550:15)
at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:565:13)
at Executor.execute (node_modules/selenium-webdriver/lib/http.js:491:26)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Driver.execute (node_modules/selenium-webdriver/lib/webdriver.js:700:17)
at async Context.<anonymous> (timeSheet.js:18:46)