jeSKA
(jeSKA)
May 21, 2013, 7:17am
#1
запускаю Selenium Server через bat
java - jar selenium - server . jar - userExtensions user - extensions . js - Dwebdriver . ie . driver =.\ IEDriverServer . exe
,далее в IDE запускаю тест, браузер открывается но методы goto,label,while не видит(. В чём может быть проблема? файл user-extensions.js в дирректории с сервером.
XGor
(XGor)
May 23, 2013, 11:23am
#2
Когда я так запускал, делал так:
1. user - extensions . js надо запихать внутрь jar
2. В user - extensions . js надо дописать (уже не помню откуда это брал):
/* (C) Copyright MetaCommunications, Inc. 2006. http://www.meta-comm.com http://engineering.meta-comm.com Distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. */ function map_list( list, for_func, if_func ) { var mapped_list = []; for ( var i = 0; i < list.length; ++i ) { var x = list[i]; if( null == if_func || if_func( i, x ) ) mapped_list.push( for_func( i, x ) ); } return mapped_list; } // Modified to initialize GoTo labels/cycles list HtmlRunnerTestLoop.prototype.old_initialize = HtmlRunnerTestLoop.prototype.initialize HtmlRunnerTestLoop.prototype.initialize = function(htmlTestCase, metrics, seleniumCommandFactory) { this.gotoLabels = {}; this.whileLabels = { ends: {}, whiles: {} }; this.old_initialize(htmlTestCase, metrics, seleniumCommandFactory); this.initialiseLabels(); } HtmlRunnerTestLoop.prototype.initialiseLabels = function() { var command_rows = map_list( this.htmlTestCase.getCommandRows() , function(i, x) { return x.getCommand() } ); var cycles = []; for( var i = 0; i < command_rows.length; ++i ) { switch( command_rows[i].command.toLowerCase() ) { case "label": this.gotoLabels[ command_rows[i].target ] = i; break; case "while": case "endwhile": cycles.push( [command_rows[i].command.toLowerCase(), i] ) break; } } var i = 0; while( cycles.length ) { if( i >= cycles.length ) throw new Error( "non-matching while/endWhile found" ); switch( cycles[i][0] ) { case "while": if( ( i+1 < cycles.length ) && ( "endwhile" == cycles[i+1][0] ) ) { // pair found this.whileLabels.ends[ cycles[i+1][1] ] = cycles[i][1] this.whileLabels.whiles[ cycles[i][1] ] = cycles[i+1][1] cycles.splice( i, 2 ); i = 0; } else ++i; break; case "endwhile": ++i; break; } } } HtmlRunnerTestLoop.prototype.continueFromRow = function( row_num ) { if( row_num == undefined || row_num == null || row_num < 0 ) throw new Error( "Invalid row_num specified." ); this.htmlTestCase.nextCommandRowIndex = row_num; } // do nothing. simple label Selenium.prototype.doLabel = function(){}; Selenium.prototype.doGotolabel = function( label ) { if( undefined == htmlTestRunner.currentTest.gotoLabels[label] ) throw new Error( "Specified label '" + label + "' is not found." ); htmlTestRunner.currentTest.continueFromRow( htmlTestRunner.currentTest.gotoLabels[ label ] ); }; Selenium.prototype.doGoto = Selenium.prototype.doGotolabel; Selenium.prototype.doGotoIf = function( condition, label ) { if( eval(condition) ) this.doGotolabel( label ); } Selenium.prototype.doWhile = function( condition ) { if( !eval(condition) ) { var last_row = htmlTestRunner.currentTest.htmlTestCase.nextCommandRowIndex - 1 var end_while_row = htmlTestRunner.currentTest.whileLabels.whiles[ last_row ] if( undefined == end_while_row ) throw new Error( "Corresponding 'endWhile' is not found." ); htmlTestRunner.currentTest.continueFromRow( end_while_row + 1 ); } } Selenium.prototype.doEndWhile = function() { var last_row = htmlTestRunner.currentTest.htmlTestCase.nextCommandRowIndex - 1 var while_row = htmlTestRunner.currentTest.whileLabels.ends[ last_row ] if( undefined == while_row ) throw new Error( "Corresponding 'While' is not found." ); htmlTestRunner.currentTest.continueFromRow( while_row ); }