Saturday, 2 January 2016

How to run script from console (F12 - Devloper Tools) in mozilla firefox browser AND How to use Java script in selenium




we can run the selenium script in console then we can verify those results

-> Open the debloper tools in mozilla firefox by pressing "F12".

-> click "console", Here we can see the commands(run,clear,copy..) in right hand side.

-> Here we can type the code like below and click "Run" and verify the result,


For Click   = document.getElementById('submit').click();


For Enter Value  = document.getElementById('gs_h0').value='Selenium';


For Tab = $('#gs_htif0').keyup();


-> use below java script executor commands in selenium for above script


JavascriptExecutor js = (JavascriptExecutor) driver1;

js.executeScript("document.getElementById('submit').click();");

js.executeScript("document.getElementById('gs_h0').value='Selenium';");



js.executeScript("$('#gs_h0').keyup();");


Example


Object for drop down populated using java script



js.executeScript("$('#homeAddressZip').keyup();");


No comments:

Post a Comment