How do I load a javascript file into the DOM using selenium?

后端 未结 2 1767
失恋的感觉
失恋的感觉 2020-12-01 03:22

I\'m using Selenium WebDriver to try to insert an external javascript file into the DOM, rather than type out the entire thing into executeScript.

It looks like it p

2条回答
  •  情话喂你
    2020-12-01 03:55

    Injecting our JS-File into DOM

    Injecting our JS-File into browsers application from our local server, so that we can access our function using document object.

    injectingToDOM.js

    var getHeadTag = document.getElementsByTagName('head')[0]; 
    var newScriptTag = document.createElement('script'); 
    newScriptTag.type='text/javascript'; 
    newScriptTag.src='http://localhost:8088/WebApplication/OurOwnJavaScriptFile.js';
    // adding 
    
                                     
                  
提交回复
热议问题