How to iterate findChildren ?

28 views
Skip to first unread message

Дмитрий Шатов

unread,
Mar 16, 2021, 5:26:35 AM3/16/21
to Galen Framework
Hello everyone. Trying to use findChildren (locator). How to refer to each WebElement when using this feature.
I tried doing like this
        var elements =  myPage.findElements("a");
        for (var e of elements) {
            console.log(e.getText());
        }

As a result, I get an error in the console
$ galen.bat test Cake/Verba/home.test.js --htmlreport Cake/Verba/report
Exception in thread "main" java.lang.RuntimeException: org.mozilla.javascript.EvaluatorException: missing ; after for-loop initializer (C:\WebDriver\galen\Cake\Verba\home.test.js#24)
        at com.galenframework.GalenMain.execute(GalenMain.java:60)
        at com.galenframework.GalenMain.main(GalenMain.java:78)
Caused by: org.mozilla.javascript.EvaluatorException: missing ; after for-loop initializer (C:\WebDriver\galen\Cake\Verba\home.test.js#24)
        at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:77)
        at org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:64)
        at org.mozilla.javascript.Parser.addError(Parser.java:254)
        at org.mozilla.javascript.Parser.reportError(Parser.java:322)
        at org.mozilla.javascript.Parser.reportError(Parser.java:316)
        at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:487)
        at org.mozilla.javascript.Parser.mustMatchToken(Parser.java:477)
        at org.mozilla.javascript.Parser.forLoop(Parser.java:1462)
        at org.mozilla.javascript.Parser.statementHelper(Parser.java:1156)
        at org.mozilla.javascript.Parser.statement(Parser.java:1098)
        at org.mozilla.javascript.Parser.parseFunctionBody(Parser.java:740)
        at org.mozilla.javascript.Parser.function(Parser.java:905)
        at org.mozilla.javascript.Parser.primaryExpr(Parser.java:2994)
        at org.mozilla.javascript.Parser.memberExpr(Parser.java:2631)
        at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2529)
        at org.mozilla.javascript.Parser.mulExpr(Parser.java:2454)
        at org.mozilla.javascript.Parser.addExpr(Parser.java:2438)
        at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2419)
        at org.mozilla.javascript.Parser.relExpr(Parser.java:2394)
        at org.mozilla.javascript.Parser.eqExpr(Parser.java:2366)
        at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2355)
        at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2344)
        at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2333)
        at org.mozilla.javascript.Parser.andExpr(Parser.java:2322)
        at org.mozilla.javascript.Parser.orExpr(Parser.java:2311)
        at org.mozilla.javascript.Parser.condExpr(Parser.java:2275)
        at org.mozilla.javascript.Parser.assignExpr(Parser.java:2238)
        at org.mozilla.javascript.Parser.argumentList(Parser.java:2598)
        at org.mozilla.javascript.Parser.memberExprTail(Parser.java:2748)
        at org.mozilla.javascript.Parser.memberExpr(Parser.java:2667)
        at org.mozilla.javascript.Parser.unaryExpr(Parser.java:2529)
        at org.mozilla.javascript.Parser.mulExpr(Parser.java:2454)
        at org.mozilla.javascript.Parser.addExpr(Parser.java:2438)
        at org.mozilla.javascript.Parser.shiftExpr(Parser.java:2419)
        at org.mozilla.javascript.Parser.relExpr(Parser.java:2394)
        at org.mozilla.javascript.Parser.eqExpr(Parser.java:2366)
        at org.mozilla.javascript.Parser.bitAndExpr(Parser.java:2355)
        at org.mozilla.javascript.Parser.bitXorExpr(Parser.java:2344)
        at org.mozilla.javascript.Parser.bitOrExpr(Parser.java:2333)
        at org.mozilla.javascript.Parser.andExpr(Parser.java:2322)
        at org.mozilla.javascript.Parser.orExpr(Parser.java:2311)
        at org.mozilla.javascript.Parser.condExpr(Parser.java:2275)
        at org.mozilla.javascript.Parser.assignExpr(Parser.java:2238)
        at org.mozilla.javascript.Parser.expr(Parser.java:2217)
        at org.mozilla.javascript.Parser.nameOrLabel(Parser.java:1970)
        at org.mozilla.javascript.Parser.statementHelper(Parser.java:1229)
        at org.mozilla.javascript.Parser.statement(Parser.java:1098)
        at org.mozilla.javascript.Parser.parse(Parser.java:642)
        at org.mozilla.javascript.Parser.parse(Parser.java:601)
        at org.mozilla.javascript.Context.compileImpl(Context.java:2514)
        at org.mozilla.javascript.Context.compileReader(Context.java:1458)
        at org.mozilla.javascript.Context.compileReader(Context.java:1430)
        at org.mozilla.javascript.Context.evaluateReader(Context.java:1272)
        at com.galenframework.javascript.GalenJsExecutor.eval(GalenJsExecutor.java:101)
        at com.galenframework.runner.JsTestCollector.execute(JsTestCollector.java:60)
        at com.galenframework.actions.GalenActionTest.runTestFiles(GalenActionTest.java:103)
        at com.galenframework.actions.GalenActionTest.execute(GalenActionTest.java:87)
        at com.galenframework.GalenMain.execute(GalenMain.java:58)
        ... 1 more

Reply all
Reply to author
Forward
0 new messages