0

We have tried using selenium for testing, but it has numerous setbacks, delays and sudden crashes. Jquery sounds a good alternative, but the challenge is how to jquerify every page load on the browser.

Brandon Martinez here has an example of how to add jquery to the console of chrome to jquerify a page:

var element1 = document.createElement("script");
element1.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js";
element1.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(element1);

we want that code to automatically be available in every browser page without the need to manually click a bookmark link on every page.

If we get around that then we can use C# code to:

Process.Start("chrome", @"target site");

and since jquery is already available for every page it will do the population and submit we want.

How can I automatically include jquery for every page that gets loaded on the browser? Is it possible to do that via a chrome plugin; jquery or C# code!? Is it at all possible?

user1019042
  • 2,428
  • 9
  • 43
  • 85
  • If you're testing your own site, why not simply load jQuery in the HTML of the site? – IMSoP May 03 '14 at 18:41
  • Also, how are you going to automate the population and submission of data? Why can that automation not load jQuery using the snippet you have before proceeding with other actions? – IMSoP May 03 '14 at 18:42
  • @IMSoP thx. Yes loading modern jquery library is the direction we were going to go with in the next release of the site. For the automation we will create a C# simple console app to process start chrome page. Upon the load of any page in that machine, we need jquery be somehow hooked up to the page automatically (no human interaction with the chrome console or clicking on any button in browser to juqerify the page). The automatically loaded jquery will then do the automation we wanted. I hope this explains it more clearly. – user1019042 May 03 '14 at 23:26
  • Not really. Do you mean the script you are going to load includes both jQuery and some automated actions? jQuery itself is just a function library, so won't preform any tasks just by being loaded. – IMSoP May 04 '14 at 17:25
  • @IMSoP here is an example. 1. download jquery injection for chrome v. 2.1.0. it will show up on the toolbar of the chrome browser 2. Go to any site like www.yahoo.com. Let's assume this is the site we will need to test against. 3. F12 it to reveal the Elements tab 4. Click on the jquery injection icon. A – user1019042 May 04 '14 at 19:27
  • Sure, but what I don't get is what you're going to do with those 1000 pages next. If it involves executing some JS (which happens to use jQuery functions) then you still have to work out how to run *that* JS without human interaction. And if you can do that, you can just tack the "jquerify" snippet onto the front of your automation JS. – IMSoP May 04 '14 at 20:16
  • @IMSoP Yes, after the 1000 pages, I will need to execute javascript. So, you are separating between A. automatically appending the juqery reference and B. executing it. Fair enough! If I can get help with #A then I can worry about executing that JS. New development regarding this... I am thinking about using auto-hotkey to automate the clicking of the jquery and even filling the form, but I don't like this option very much; I would rather do the automation by code. – user1019042 May 04 '14 at 21:24
  • Well, assuming you've got a bunch of automation tasks in a list somewhere, sticking the jquerify snippet on the front of all of them should be easy - even if you just copy-and-paste it in a text editor. So the question becomes "how do I open 1000 browser windows, and run different prepared JS in each of them". Which strikes me as exactly what tools like selenium are designed for... – IMSoP May 04 '14 at 21:28

1 Answers1

0

I've decided to use Fiddler to modify response body before being displayed on the browser. Now I can jquerify all pages comes to the browser. Look at this link for a detailed example.

Community
  • 1
  • 1
user1019042
  • 2,428
  • 9
  • 43
  • 85