I am getting an error:
Cannot read property 'click' of undefined
while trying to click a button using java script executor. I have tried many different approach to click the button using action classes, webdriverwait etc but none seems to work.Java Script is working in console but when i am using in my code i am unable to click the button and getting the mentioned error
The html dom looks as below:
<div>
<a class="button button--new-resource" href="/admin/certificate_types/new">
<img src="/assets/icon-add-user-e2a98953aa1855b15304eb16415b536ee92e579ce89f429bcdd062faa855e261.svg" alt="Icon add user"> New Certificate Type
</a>
</div>
My selenium script is as below
JavascriptExecutor js=(JavascriptExecutor) driver;
js.executeScript("var x= document.getElementsByClassName('button button--new-resource')[0];"+"x.click();");
from Cannot read property 'click' of undefined while using Java Script Executor in Selenium
No comments:
Post a Comment