Load JS script from file system and execute it with selenium

I'm truing to execute a yui js script with js.executeScript Selenium's method. The script is being executed by selenium webdriver in order simulate a "click" on hybrid mobile app (the button is webview)

 String IncludeYUI = "script = document.createElement('script');script.type = 'text/javascript';script.async = true;script.onload = function(){};script.src = '"
                    + YUI_PATH
                    + "';document.getElementsByTagName('head')[0].appendChild(script);";

where the YUI_PATH is an url - https://cdnjs.cloudflare.com/ajax/libs/yui/3.18.0/yui/.....

The problem is that I do not have an access to the global network from the current site.

so I was thinking to save the script under the project and just to load it from FS. But this is a js , no access to the FS ...

Any ideas how to load the script ?



So, you're loading an html page somewhere, right? Conceptually you would load your JS file the same way: you make a request to your server to load the JS file, just like you did to load your html page.

That would look like this:

<script src="scripts/yourFile.js">

Also, I've never seen anyone loading a js file like you're doing in your code sample...I would most definitely just recommend putting a script tag in your html.

You may want to post your html code as well; we'll be able to provide better help. I'll update this answer accordingly if needed.

Finally , after many tries , some1 has suggested me to work with jquery. after some digging , I've used executeScript with jquery's tap , and it worked...


I was wondering all other methods with click and element's coordinates didn't work

Need Your Help


actionscript-3 flex flash-builder4.5 flashbuilder4

Following creation complete event not working on remote server.Working fine on local.

pass array of arrays from routes to view node.js

node.js express handlebars.js

I am trying to pass an array of arrays from routes to view page. My data that I am trying to pass is :