Как выполнить JavaScript Selenium - TypeError: .... не определено - PullRequest
0 голосов
/ 30 августа 2018

Я хочу выполнить скрипт:

if(driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver) 
.executeScript("zaznaczKomorke(0,\"\",document.getElementById('TABELA_EIS_0').childNodes[1].childNodes[0].childNodes[0])"); 

}  
if(driver instanceof JavascriptExecutor) {
((JavascriptExecutor) driver) 
        .executeScript("usunK()");}

но у меня ошибка:

Exception in thread "main" org.openqa.selenium.JavascriptException: TypeError: komorka_EIS is undefined
Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
System info: host: 'GR4-0013663', ip: '10.5.80.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\\AppData\Local\Temp\rust_mozprofile.mBDoywlmJypJ, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=XP, moz:accessibilityChecks=false, moz:useNonSpecCompliantPointerOrigin=false, acceptInsecureCerts=true, browserVersion=61.0.2, platformVersion=6.1, moz:processID=10096, browserName=firefox, javascriptEnabled=true, platformName=XP, moz:webdriverClick=true}]
Session ID: 26da2002-ba19-4754-b699-0c8ecdd609b2
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:646)
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:582)
    at Dodawanie_formularza.Dodawanie_formularza.definiowanie_formularza(Dodawanie_formularza.java:204)
    at Dodawanie_formularza.Dodawanie_formularza.main(Dodawanie_formularza.java:65)

кто-нибудь может мне помочь с этим?

функция usunK () код:

function usunK(){
    var poziomWarstwy = currentRozdzial==""?0:currentRozdzial;
    var tabela = tabelaManager.znajdzElementyPoziomuRozdzialu()[currentTable];
    var tabela_EIS = document.getElementById("TABELA_EIS" + currentRozdzial + "_" + currentTable);
    var rows = parseInt(liczbaWierszy.get(poziomWarstwy)[currentTable]);
    var cols = parseInt(liczbaKolumn.get(poziomWarstwy)[currentTable]);     
    var rowsNaglCount = tabelaManager.getLiczbaWierszyNagl(tabela.rowsNagl);
    var komorka_EIS = selection.getSelectedCell_EIS();
var col = komorka_EIS.col.nr;

проблема для функции usunK ()

Функция zaznaczKomorke выполняется хорошо, и я не вижу ошибок на консоли

Есть идеи ??

...