Shafayat Alam Shafayat Alam - 4 months ago 43
Node.js Question

jQuery with slenium-webdriver in Node.JS

Can anyone please tell me how to use jQuery with selenium-webdriver to scrape some web page with Node.JS

My current code looks like this

driver.get(args.bookingURL).then(function () {
return driver.executeScript("\
$('#customer_login_email').val('sonetsobuj@gmail.com');\
$('#customer_login_password').val('*******');\
");
}).then(function () {
console.log('Button Will be Clicked');
return driver.executeScript("$('#customer_login').click();");
});


When I execute this script terminal shows this


JavascriptError: $ is not defined

Answer

use the script like below:

driver.executeScript("$('#customer_login_email').val('sonetsobuj@gmail.com'); "
            + "$('#customer_login_password').val('*******');");
    }

when you enter script in new line you have to add an extra + in your script.

u can go through this page to check how to add jquery in DOM http://sqa.stackexchange.com/questions/2921/webdriver-can-i-inject-a-jquery-script-for-a-page-that-isnt-using-jquery

Comments