I have tried this too. 

This is my code block: 

var elem = dvr.findElement(By.xpath("//tr[contains(.,'xxx')]"));
if (elem.isEmpty()){
console.log('Not displayed' + i);
//count++;
dvr.findElement(By.xpath("//a[contains(.,'ยป')]"));
}
else {
console.log('Displayed in page' + i);
dvr.findElement(By.xpath("//tr[contains(.,'xxx')]/td[3]/a"));
dvr.switchTo().alert().accept();
}


This is the error I get:
elem.isEmpty is not a function

Why is this happening? 


On Monday, 3 September 2018 12:04:30 UTC+5:30, siva prasad wrote:
>
> I am fairly new to the JS scripting. 
> Started using JS for end-to-end test case automation.
>
> I am facing an issue here. 
>
> *Issue: *
> UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: 
> Unable to locate element: {"method":"link text","selector":"Business 
> Continuity"}
>   (Session info: chrome=68.0.3440.106)
>   (Driver info: chromedriver=2.35.528157 
> (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.13.2 x86_64)
>     at Object.checkLegacyResponse 
> (/Users/sivaprasad/node_modules/selenium-webdriver/lib/error.js:585:15)
>     at parseHttpResponse 
> (/Users/sivaprasad/node_modules/selenium-webdriver/lib/http.js:533:13)
>     at Executor.execute 
> (/Users/sivaprasad/node_modules/selenium-webdriver/lib/http.js:468:26)
>     at <anonymous>
>     at process._tickCallback (internal/process/next_tick.js:188:7)
> (node:25855) 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(). (rejection id: 1)
> (node:25855) [DEP0018] DeprecationWarning: Unhandled promise rejections 
> are deprecated. In the future, promise rejections that are not handled will 
> terminate the Node.js process with a non-zero exit code.
>
> *Code:*
>
> driver.findElement(By.id('username')).sendKeys('xxx');
> driver.findElement(By.id('password')).sendKeys('xxx');
> driver.findElement(By.id('submit')).click();
> driver.findElement(By.linkText('Business Continuity')).click();
>
> I know there is something called Promise handling. Just that I am not able 
> to get my head around it. Someone help me. 
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/d08b24d8-28d8-41c8-9c74-50164b62b63a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to