0
나는 셀레늄과 자바 스크립트를 처음 사용함. 셀렌 컨트롤 브라우저에서 여는 페이지에 VisualEvent라는 javascript를로드하려고합니다. Java의 셀레늄에서 변수에 액세스합니다. 첫 번째 단계는 아래에 의해 완벽하게 수행됩니다셀렌에서 창 객체 액세스하기
driver = new FirefoxDriver();
driver.get("http://stackoverflow.com/");
String script = //Minified of below script
//////////////
(function() {
var protocol = window.location.protocol === 'file:' ? 'http:' : '';
var url = protocol + '//www.sprymedia.co.uk/VisualEvent/VisualEvent_Loader.js';
if (typeof VisualEvent != 'undefined') {
if (VisualEvent.instance !== null) {
VisualEvent.close();
} else {
new VisualEvent();
}
} else {
var n = document.createElement('script');
n.setAttribute('language', 'JavaScript');
n.setAttribute('src', url + '?rand=' + new Date().getTime());
document.body.appendChild(n);
}
})();
///////////////////////
Object[] a = { null, null, null };
driver.executeScript(script, a);
하지만 난 액세스 할 때 window.VisualEvent
:
script = "return window.VisualEvent.instance;";
Object b = driver.executeScript(script, a);
이 execption가 발생합니다
: 난 같은이 실행
Exception in thread "main" org.openqa.selenium.JavascriptException: TypeError: window.VisualEvent is undefined
동안 브라우저 콘솔 내가 참조를 얻을 것이다. 또한 셀레늄의 winow.document
개체에 액세스 할 수 있습니다. 아이디어가 있으십니까?
스크립트 완료를 기다리는 중입니다. –