I was using css to locate element, i was trying to avoid xpath just in case, but im having trouble with the element. Im still getting error:
(node:7516) UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"[name-firstName]"}
It only works on xpath, but i want to use css locator. Is it a good practice to avoid xpath when locating element? thank you guys!
Here is the whole element:
<input type="text" class="f w-input ng-pristine ng-invalid ng-invalid-required ng-touched" name="firstName" required="" ng-readonly="vm.showLoading" ng-model="vm.formData.firstName" placeholder="Your First Name">
Here is the code trial :
driver.get("www.examplewebsiteonly.com")
.then(function() {
return driver.wait(until.elementLocated(By.css('[name=firstName]')), 20000)
.then(function(){
driver.sleep(20000)
.then(function(){
return driver.findElement(By.css('[name-firstName]')).sendKeys("FirstName");
})
})
})