/test/sahi/htdocs/spr/concat3.js
JavaScript | 3116 lines | 2871 code | 61 blank | 184 comment | 756 complexity | 291afc3ebf7783a3b7b9900c44d2c2de MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, JSON, LGPL-2.1, MPL-2.0-no-copyleft-exception
Large files files are truncated, but you can click here to view the full file
- /**
- * Sahi - Web Automation and Test Tool
- *
- * Copyright 2006 V Narayan Raman
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- String.isBlankOrNull = function (s) {
- return (s == "" || s == null);
- };
-
- var Sahi = function(){
- this.cmds = new Array();
- this.cmdDebugInfo = new Array();
-
- this.cmdsLocal = new Array();
- this.cmdDebugInfoLocal = new Array();
-
- this.waitInterval = -1;
-
- this.promptReturnValue = new Array();
- this.waitCondition = null;
-
- this.locals = [];
-
- this.INTERVAL = 100;
- this.ONERROR_INTERVAL = 1000;
- this.MAX_RETRIES = 5;
- this.SAHI_MAX_WAIT_FOR_LOAD = 30;
- this.waitForLoad = this.SAHI_MAX_WAIT_FOR_LOAD;
- this.interval = this.INTERVAL;
- this.localIx = 0;
- this.buffer = "";
-
- this.controller = null;
- this.lastAccessedInfo = null;
- this.execSteps = null; // from SahiScript through script.js
-
- this.sahiBuffer = "";
-
- this.real_alert = window.alert;
- this.real_confirm = window.confirm;
- this.real_prompt = window.prompt;
- this.real_print = window.print;
- this.wrapped = new Array();
- this.mockDialogs();
-
- this.XHRs = [];
- this.escapeMap = {
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- };
- this.lastStepId = 0;
- this.diagnostics = new Object();
- this.storeDiagnostics();
- this.strictVisibilityCheck = false;
- this.ADs = [];
- this.lastBrowserMessageId = null;
- this._isRecording = false;
- this.NORMAL_LISTEN_INTERVAL = 1500;
- this.unreachableCount = 0;
- this.IDLE_LISTEN_INTERVAL = 4000;
- this.listenInterval = this.NORMAL_LISTEN_INTERVAL;
- this.activeCount = 0;
- };
- Sahi.prototype.relisten = function(){
- this.activeCount = 0;
- if (this.listenTimeoutId) window.clearTimeout(this.listenTimeoutId);
- this.listen();
- };
- Sahi.prototype.listen = function(){
- try{
- var msg = this.getMessageForBrowser();
- }catch(e){
- this.unreachableCount++;
- this.listenInterval = this.listenInterval*2;
- if (this.unreachableCount > 5) return;
- return window.setTimeout("_sahi.listen()", this.listenInterval);
- }
- this.listenInterval = this.NORMAL_LISTEN_INTERVAL;
- if (msg != null && msg != "null" && msg.id != this.lastBrowserMessageId){
- this.lastBrowserMessageId = msg.id;
- var res = null;
- try{
- var cmd = msg.command;
- if (cmd != null && cmd != ""){
- eval(cmd);
- }
- }catch (e){
-
- }
- }else{
- if (this.activeCount > 20){
- this.listenInterval = this.IDLE_LISTEN_INTERVAL;
- }else this.activeCount++;
- }
- this.listenTimeoutId = window.setTimeout("_sahi.listen()", this.listenInterval);
- };
- Sahi.prototype.getMessageForBrowser = function(){
- var url = "/_s_/dyn/Messages_getMessageForBrowser?windowName="+this.getPopupName();
- return eval("("+this.sendToServer(url, false, true)+")");
- };
- Sahi.prototype.processMessage = function(s){
- s = this.addSahi(s);
- this.setServerVar("sahiEvaluateExpr", true);
- try{
- this.top().eval(s);
- }catch(e){}
- this.setServerVar("sahiEvaluateExpr", false);
- };
- Sahi.prototype.sendToController = function(message, mode){
- this.setServerVarAsync("CONTROLLER_MessageForController", {mode:mode, message:message});
- };
- Sahi.prototype.sendIdsToController = function(elInfo, mode){
- var identifiers = elInfo.apis;
- var windowName = this.getPopupName();
- var s = "";
- if (identifiers == null || identifiers.length == 0) {
- s = {accessor: null, alternatives: [], windowName: windowName, value: null, script: null, mode: mode};
- } else {
- var id0 = identifiers[0];
- var value = this.escapeValue(id0.value);
- var accessors = [];
- for ( var i = 0; i < identifiers.length; i++) {
- accessors[i] = this.escapeDollar(this.getAccessor1(identifiers[i]));
- }
- var script = this.getScript(id0);
- s = {accessor: accessors[0], alternatives: accessors, windowName: windowName, value: value, script: script, mode: mode, assertions: elInfo.assertions};
- }
- // this.getController()._c.processMessage(s);
- this.setServerVarAsync("CONTROLLER_MessageForController", s);
- };
- Sahi.prototype.getAssertions = function(accs, info){
- var a = ["_assertExists(<accessor>)"];
- for (var k=0; k<accs.length; k++){
- var acc = accs[k];
- if (acc.assertions)
- a = a.concat(acc.assertions(info.value));
- }
- if (info.valueType == "sahiText"){
- a[a.length] = "_assertEqual(<value>, _getText(<accessor>))";
- a[a.length] = "_assertContainsText(<value>, <accessor>)";
- } else if (info.valueType == "value"){
- a[a.length] = "_assertEqual(<value>, <accessor>.value)";
- }
- return a;
- };
- Sahi.prototype.sendResultToController = function(result){
- this.setServerVar("CONTROLLER_MessageForController", {result: result});
- };
- Sahi.prototype.storeDiagnostics = function(){
- var d = this.diagnostics;
- d["UserAgent"] = navigator.userAgent;
- d["Native XMLHttpRequest"] = typeof XMLHttpRequest != "undefined";
- };
- Sahi.prototype.printDiagnostics = function(){
- var s = this.getDiagnostics();
- this._debug(s);
- return s;
- };
- Sahi.prototype.getDiagnostics = function(){
- var s = "";
- for (var key in this.diagnostics){
- s += key +": "+ this.diagnostics[key]+"\n";
- }
- return s;
- };
- Sahi.prototype.wrap = function (fn) {
- var el = this;
- if (this.wrapped[fn] == null) {
- this.wrapped[fn] = function(){fn.apply(el, arguments);};
- }
- return this.wrapped[fn];
- };
- Sahi.prototype.alertMock = function (s) {
- if (this.isPlaying()) {
- this.setServerVar("lastAlertText", s);
- return null;
- } else {
- return this._alert(s);
- }
- };
- Sahi.prototype.confirmMock = function (s) {
- if (this.isPlaying()) {
- var retVal = eval(this.getServerVar("confirm: "+s));
- if (retVal == null) retVal = true;
- this.setServerVar("lastConfirmText", s);
- this.setServerVar("confirm: "+s, null);
- return retVal;
- } else {
- var retVal = this.callFunction(this.real_confirm, window, s);
- if (this.isRecording()){
- this.recordStep("_expectConfirm(\"" + s + "\", " + retVal + ")");
- // this.sendToServer('/_s_/dyn/Recorder_record?cmd=' + encodeURIComponent("_expectConfirm(\"" + s + "\", " + retVal + ")"));
- }
- return retVal;
- }
- };
- Sahi.prototype.promptMock = function (s) {
- if (this.isPlaying()) {
- var retVal = this.getServerVar("prompt: "+s);//this.promptReturnValue[s];
- if (retVal == null) retVal = "";
- this.setServerVar("lastPromptText", s);
- this.setServerVar("prompt: "+s, null);
- return retVal;
- } else {
- var retVal = this.callFunction(this.real_prompt, window, s);
- this.recordStep("_expectPrompt(\"" + s + "\", \"" + retVal + "\")");
- // this.sendToServer('/_s_/dyn/Recorder_record?cmd=' + encodeURIComponent("_expectPrompt(\"" + s + "\", \"" + retVal + "\")"));
- return retVal;
- }
- };
- Sahi.prototype.printMock = function () {
- if (this.isPlaying()) {
- this.setServerVar("printCalled", true);
- return null;
- } else {
- return this.callFunction(this.real_print, window);
- }
- };
- Sahi.prototype.mockDialogs = function (e) {
- window.alert = this.wrap(this.alertMock);
- window.confirm = this.wrap(this.confirmMock);
- window.prompt = this.wrap(this.promptMock);
- window.print = this.wrap(this.printMock);
- };
- //_sahi.mockDialogs();
- var _sahi = new Sahi();
- var tried = false;
- var _sahi_top = window.top;
- Sahi.prototype.top = function () {
- //Hack for frames named "top"
- try{
- var x = _sahi_top.location.href; // test
- return _sahi_top;
- }catch(e){
- var p = window;
- while (p != p.parent){
- try{
- var y = p.parent.location.href; // test
- p = p.parent;
- }catch(e){
- return p;
- }
- }
- return p;
- }
- };
- Sahi.prototype.getKnownTags = function (src) {
- return src;
- var el = src;
- while (true) {
- if (!el) return src;
- if (!el.tagName || el.tagName.toLowerCase() == "html" || el.tagName.toLowerCase() == "body") return null;
- var tag = el.tagName.toLowerCase();
- if (tag == "a" || tag == "select" || tag == "img" || tag == "form"
- || tag == "input" || tag == "button" || tag == "textarea"
- || tag == "textarea" || tag == "td" || tag == "table"
- || ((tag == "div" || tag == "span")) || tag == "label" || tag == "li" ) return el;
- el = el.parentNode;
- }
- };
- var linkClick = function (e) {
- if (!e) e = window.event;
- var performDefault = true;
- if (this.prevClick) {
- performDefault = this.prevClick.apply(this, arguments);
- }
- //_sahi.real_alert(e);
- _sahi.lastLinkEvent = e;
- _sahi.lastLink = this;
- if (performDefault != false) {
- window.setTimeout(function(){_sahi.navigateLink()}, 10);
- } else {
- return false;
- }
- };
- Sahi.prototype._dragDrop = function (draggable, droppable) {
- this.checkNull(draggable, "_dragDrop", 1, "draggable");
- this.checkNull(droppable, "_dragDrop", 2, "droppable");
- var pos = this.findPos(droppable);
- var x = pos[0];
- var y = pos[1];
- this._dragDropXY(draggable, x, y);
- };
- Sahi.prototype.addBorder = function(el){
- el.style.border = "1px solid red";
- };
- Sahi.prototype._dragDropXY = function (draggable, x, y, isRelative) {
- this.checkNull(draggable, "_dragDropXY", 1, "draggable");
- this.simulateMouseEvent(draggable, "mousemove");
- this.simulateMouseEvent(draggable, "mousedown");
- this.simulateMouseEvent(draggable, "mousemove");
-
- var addX = 0, addY = 0;
- if (isRelative){
- var pos = this.findPos(draggable);
- addX = pos[0];
- addY = pos[1];
- if (!x) x = 0;
- if (!y) y = 0;
- x += addX;
- y += addY;
- }else{
- if (!x) x = this.findPos(draggable)[0];
- if (!y) y = this.findPos(draggable)[1];
- }
-
- this.simulateMouseEventXY(draggable, "mousemove", x, y);
- this.simulateMouseEventXY(draggable, "mouseup", x, y);
- this.simulateMouseEventXY(draggable, "click", x, y);
- this.simulateMouseEventXY(draggable, "mousemove", x, y);
- };
- Sahi.prototype.checkNull = function (el, fnName, paramPos, paramName) {
- if (el == null) {
- throw new Error("The " +
- (paramPos==1?"first ":paramPos==2?"second ":paramPos==3?"third ":"") +
- "parameter passed to " + fnName + " was not found on the browser");
- }
- };
- Sahi.prototype.checkVisible = function (el) {
- if (this.strictVisibilityCheck && !this._isVisible(el)) {
- throw "" + el + " is not visible";
- }
- };
- Sahi.prototype._isVisible = function (el) {
- try{
- if (el == null) return false;
- var elOrig = el;
- var display = true;
- while (true){
- display = display && this.isStyleDisplay(el);
- if (!display || el.parentNode == el || el.tagName == "BODY") break;
- el = el.parentNode;
- }
- el = elOrig;
- var visible = true;
- while (true){
- visible = visible && this.isStyleVisible(el);
- if (!visible || el.parentNode == el || el.tagName == "BODY") break;
- el = el.parentNode;
- }
- return display && visible;
- } catch(e){return true;}
-
- };
- Sahi.prototype.isStyleDisplay = function(el){
- var d = this._style(el, "display");
- return d==null || d != "none";
- };
- Sahi.prototype.isStyleVisible = function(el){
- var v = this._style(el, "visibility");
- return v==null || v != "hidden";
- };
- Sahi.prototype._click = function (el) {
- this.checkNull(el, "_click");
- this.checkVisible(el);
- this.simulateClick(el, false, false);
- };
-
- Sahi.prototype._doubleClick = function (el) {
- this.checkNull(el, "_doubleClick");
- this.checkVisible(el);
- this.simulateClick(el, false, true);
- };
-
- Sahi.prototype._rightClick = function (el) {
- this.checkNull(el, "_rightClick");
- this.checkVisible(el);
- this.simulateClick(el, true, false);
- };
-
- Sahi.prototype._mouseOver = function (el) {
- this.checkNull(el, "_mouseOver");
- this.checkVisible(el);
- this.simulateMouseEvent(el, "mousemove");
- this.simulateMouseEvent(el, "mouseover");
- };
-
- Sahi.prototype._keyPress = function (el, charCode, combo) {
- this.checkNull(el, "_keyPress", 1);
- this.checkVisible(el);
- if (typeof charCode == "string"){
- charCode = charCode.charCodeAt(0);
- }
- var c = String.fromCharCode(charCode);
- var prev = el.value;
- this.simulateMouseEvent(el, "focus");
- this.simulateKeyEvent(charCode, el, "keydown", combo);
- this.simulateKeyEvent(charCode, el, "keypress", combo);
- if (prev + c != el.value) {
- // if (!el.maxLength || el.value.length < el.maxLength)
- el.value = el.value + c;
- }
- this.simulateKeyEvent(charCode, el, "keyup", combo);
- };
-
- Sahi.prototype._focus = function (el) {
- this.simulateMouseEvent(el, "focus");
- };
-
- Sahi.prototype._keyDown = function (el, charCode, combo) {
- this.checkNull(el, "_keyDown", 1);
- this.checkVisible(el);
- this.simulateKeyEvent(charCode, el, "keydown", combo);
- };
-
- Sahi.prototype._keyUp = function (el, charCode, combo) {
- this.checkNull(el, "_keyUp", 1);
- this.checkVisible(el);
- this.simulateKeyEvent(charCode, el, "keyup", combo);
- };
-
-
- Sahi.prototype._readFile = function (fileName) {
- var qs = "fileName=" + fileName;
- return this._callServer("net.sf.sahi.plugin.FileReader_contents", qs);
- };
- Sahi.prototype._getDB = function (driver, jdbcurl, username, password) {
- return new Sahi.dB(driver, jdbcurl, username, password, this);
- };
- Sahi.dB = function (driver, jdbcurl, username, password, sahi) {
- this.driver = driver;
- this.jdbcurl = jdbcurl;
- this.username = username;
- this.password = password;
- this.select = function (sql) {
- var qs = "driver=" + this.driver + "&jdbcurl=" + this.jdbcurl + "&username=" + this.username + "&password=" + this.password + "&sql=" + sql;
- return eval(sahi._callServer("net.sf.sahi.plugin.DBClient_select", qs));
- };
- this.update = function (sql) {
- var qs = "driver=" + this.driver + "&jdbcurl=" + this.jdbcurl + "&username=" + this.username + "&password=" + this.password + "&sql=" + sql;
- return eval(sahi._callServer("net.sf.sahi.plugin.DBClient_execute", qs));
- };
- };
- Sahi.prototype.simulateClick = function (el, isRight, isDouble) {
- var n = el;
-
- if (this.isIE() && !isRight) {
- if (el && (el.tagName == "LABEL" || (el.type && (el.type == "submit" || el.type == "button"
- || el.type == "reset" || el.type == "image"
- || el.type == "checkbox" || el.type == "radio")))) {
- el.click();
- if (el.type && (el.type == "checkbox")){
- this.simulateChange(el);
- }
- return;
- }
- }
-
- var lastN = null;
- while (n != null && n != lastN) {
- if (n.tagName && n.tagName == "A") {
- n.prevClick = n.onclick;
- n.onclick = this.getWindow(el).linkClick;
- }
- lastN = n;
- n = n.parentNode;
- }
-
- this.simulateMouseEvent(el, "mousemove");
- this.simulateMouseEvent(el, "focus");
- this.simulateMouseEvent(el, "mouseover");
- this.simulateMouseEvent(el, "mousedown", isRight);
- this.simulateMouseEvent(el, "mouseup", isRight);
- if (isRight) {
- this.simulateMouseEvent(el, "contextmenu", isRight, isDouble);
- } else {
- try {
- this.simulateMouseEvent(el, "click", isRight, isDouble);
- if (this.isSafariLike()) {
- /*
- try {
- if (el.onclick) el.onclick();
- if (el.parentNode.tagName == "A") {
- el.parentNode.onclick();
- }
- } catch(ex) {
- this._debug(ex.message);
- }
- */
- if (el.tagName == "INPUT") {
- if (typeof el.checked == "boolean") {
- el.checked = (el.type == "radio") ? true : !el.checked;
- } /* else if (el.type == "submit") {
- var goOn = el.form.onsubmit();
- if (goOn != false) {
- el.form.submit();
- this.onBeforeUnLoad();
- }
- } */
- }
- }
- } catch(e) {
- }
- }
- this.simulateMouseEvent(el, "blur");
- n = el;
- lastN = null;
- while (n != null && n != lastN) {
- if (n.tagName && n.tagName == "A") {
- n.onclick = n.prevClick;
- }
- n = n.parentNode;
- }
- };
- Sahi.prototype.isSafariLike = function () {
- return /Konqueror|Safari|KHTML/.test(navigator.userAgent);
- };
- Sahi.prototype.simulateMouseEvent = function (el, type, isRight, isDouble) {
- var xy = this.findPos(el);
- var x = xy[0];
- var y = xy[1];
- this.simulateMouseEventXY(el, type, xy[0], xy[1], isRight, isDouble);
- };
- Sahi.prototype.simulateMouseEventXY = function (el, type, x, y, isRight, isDouble) {
- if (window.document.createEvent) {
- if (this.isSafariLike()) {
- var evt = el.ownerDocument.createEvent('HTMLEvents');
- evt.initEvent(type, true, true);
- el.dispatchEvent(evt);
- }
- else {
- // FF
- var evt = el.ownerDocument.createEvent("MouseEvents");
- evt.initMouseEvent(
- (isDouble ? "dbl" : "") + type,
- true, //can bubble
- true,
- el.ownerDocument.defaultView,
- (isDouble ? 2 : 1),
- x, //screen x
- y, //screen y
- x, //client x
- y, //client y
- false,
- false,
- false,
- false,
- isRight ? 2 : 0,
- null);
- el.dispatchEvent(evt);
- }
- } else {
- // IE
- var evt = el.ownerDocument.createEventObject();
- evt.clientX = x;
- evt.clientY = y;
- evt.button = isRight ? 2 : 1;
- el.fireEvent("on" + (isDouble ? "dbl" : "") + type, evt);
- evt.cancelBubble = true;
- }
- };
- Sahi.pointTimer = 0;
- Sahi.prototype._highlight = function (el) {
- var win = this.getWin(el);
- win.scrollTo(this.findPosX(el), this.findPosY(el) - 20);
- var oldBorder = el.style.border;
- el.style.border = "1px solid red";
- window.setTimeout(function(){el.style.border = oldBorder;}, 2000);
- };
- Sahi.prototype._position = function (el){
- return this.findPos(el);
- };
- Sahi.prototype.findPosX = function (obj){
- return this.findPos(obj)[0];
- };
- Sahi.prototype.findPosY = function (obj){
- return this.findPos(obj)[1];
- };
- Sahi.prototype.findPos = function (obj){
- var x = 0, y = 0;
- if (obj.offsetParent)
- {
- while (obj.offsetParent)
- {
- var wasStatic = null;
- /*
- if (this._style(obj, "position") == "static"){
- wasStatic = obj.style.position;
- obj.style.position = "relative";
- }
- */
- x += obj.offsetLeft;
- y += obj.offsetTop;
- if (wasStatic != null) obj.style.position = wasStatic;
- obj = obj.offsetParent;
- }
- }
- else if (obj.x){
- x = obj.x;
- y = obj.y;
- }
- return [x, y];
- };
- Sahi.prototype.getWindow = function(el){
- var win;
- if (this.isSafariLike()) {
- win = this.getWin(el);
- } else {
- win = el.ownerDocument.defaultView; //FF
- if (!win) win = el.ownerDocument.parentWindow; //IE
- }
- return win;
- };
-
- Sahi.prototype.navigateLink = function () {
- var ln = this.lastLink;
- if (!ln) return;
- if (this.lastLinkEvent.getPreventDefault) {
- if (this.lastLinkEvent.getPreventDefault()) return;
- }
- if ((this.isIE() || this.isSafariLike()) && this.lastLinkEvent.returnValue == false) return;
- var win = this.getWindow(ln);
- if (ln.href.indexOf("javascript:") == 0) {
- var s = ln.href.substring(11);
- win.setTimeout(unescape(s), 0);
- } else {
- var target = ln.target;
- if (ln.target == null || ln.target == "") target = "_self";
- if (this.isSafariLike()) {
- var targetWin = win.open("", target);
- try {
- targetWin._sahi.onBeforeUnLoad();
- } catch(e) {
- this._debug(e.message);
- }
- targetWin.location.href = ln.href;
- }
- else win.open(ln.href, target);
- }
- };
-
- Sahi.prototype.getClickEv = function (el) {
- var e = new Object();
- if (this.isIE()) el.srcElement = e;
- else e.target = el;
- e.stopPropagation = this.noop;
- return e;
- };
-
- Sahi.prototype.noop = function () {
- };
-
- // api for link click end
-
- Sahi.prototype._type = function (el, val) {
- for (var i = 0; i < val.length; i++) {
- var ccode = val.charAt(i).charCodeAt(0);
- this.simulateKeyEvent(ccode, el, "keydown");
- this.simulateKeyEvent(ccode, el, "keypress");
- this.simulateKeyEvent(ccode, el, "keyup");
- }
- };
-
- Sahi.prototype._setValue = function (el, val) {
- this.setValue(el, val);
- };
- // api for set value start
- Sahi.prototype.setValue = function (el, val) {
- this.checkNull(el, "_setValue", 1);
- this.checkVisible(el);
- val = "" + val;
- var prevVal = el.value;
- if (!window.document.createEvent) el.value = val;
- if (el.type && el.type.indexOf("select") != -1) {
- } else {
- var append = false;
- el.value = "";
- if (typeof val == "string") {
- for (var i = 0; i < val.length; i++) {
- var c = val.charAt(i);
- var ccode = c.charCodeAt(0);
- this.simulateKeyEvent(ccode, el, "keydown");
- this.simulateKeyEvent(ccode, el, "keypress");
- if (i == 0 && el.value != c) {
- append = true;
- }
- if (append) {
- //if (!el.maxLength || el.value.length < el.maxLength)
- el.value += c;
- }
- this.simulateKeyEvent(ccode, el, "keyup");
- }
- }
- }
- if (!this.isIE()) this.simulateEvent(el, "blur");
- if (prevVal != val) {
- if (!this.isFF3()) this.simulateEvent(el, "change");
- }
- if (this.isIE()) this.simulateEvent(el, "blur");
- if (el && el.form){
- try{
- this.simulateEvent(el.form, "change");
- }catch(e){}
- }
- };
- Sahi.prototype._setFile = function (el, v, url) {
- if (!url) url = (String.isBlankOrNull(el.form.action) || (typeof el.form.action != "string")) ? this.getWindow(el).location.href : el.form.action;
- if (url && (q = url.indexOf("?")) != -1) url = url.substring(0, q);
- if (url.indexOf("http") != 0) {
- var loc = window.location;
- if (url.indexOf("/") == 0){
- url = loc.protocol+ "//" + loc.hostname + (loc.port ? (':'+loc.port) : '') + url;
- }else{
- var winUrl = loc.href;
- url = winUrl.substring(0, winUrl.lastIndexOf ('/') + 1) + url;
- }
- }
- this._callServer("FileUpload_setFile", "n=" + el.name + "&v=" + encodeURIComponent(v) + "&action=" + encodeURIComponent(url));
- };
-
- Sahi.prototype.simulateEvent = function (target, evType) {
- if (window.document.createEvent) {
- var evt = new Object();
- evt.type = evType;
- evt.bubbles = true;
- evt.cancelable = true;
- if (!target) return;
- var event = target.ownerDocument.createEvent("HTMLEvents");
- event.initEvent(evt.type, evt.bubbles, evt.cancelable);
- target.dispatchEvent(event);
- } else {
- var evt = target.ownerDocument.createEventObject();
- evt.type = evType;
- evt.bubbles = true;
- evt.cancelable = true;
- evt.cancelBubble = true;
- target.fireEvent("on" + evType, evt);
- }
- };
-
- Sahi.prototype.simulateKeyEvent = function (charCode, target, evType, combo) {
- var c = String.fromCharCode(charCode);
- var isShift = combo == "SHIFT" || (charCode >= 65 && charCode <= 122 && c.toUpperCase() == c);
-
- if (window.document.createEvent) { // FF
- if (this.isSafariLike()) {
- var event = target.ownerDocument.createEvent('HTMLEvents');
-
- var evt = event;
- evt.bubbles = true;
- evt.cancelable = true;
- evt.ctrlKey = combo == "CTRL";
- evt.altKey = combo == "ALT";
- evt.metaKey = combo == "META";
- evt.charCode = charCode;
- evt.keyCode = charCode;
- evt.shiftKey = isShift;
-
-
- event.initEvent(evType, false, false);
- target.dispatchEvent(event);
- } else {
- var evt = new Object();
- evt.type = evType;
- evt.bubbles = true;
- evt.cancelable = true;
- evt.ctrlKey = combo == "CTRL";
- evt.altKey = combo == "ALT";
- evt.metaKey = combo == "META";
- if (charCode >= 31 && charCode <= 256){
- evt.charCode = charCode;
- evt.keyCode = 0;
- }else{
- evt.charCode = 0;
- evt.keyCode = charCode;
- }
- evt.shiftKey = isShift;
-
- if (!target) return;
- var event = target.ownerDocument.createEvent("KeyEvents");
- event.initKeyEvent(evt.type, evt.bubbles, evt.cancelable, target.ownerDocument.defaultView,
- evt.ctrlKey, evt.altKey, evt.shiftKey, evt.metaKey, evt.keyCode, evt.charCode);
- target.dispatchEvent(event);
- }
- } else {
- var evt = target.ownerDocument.createEventObject();
- evt.type = evType;
- evt.bubbles = true;
- evt.cancelable = true;
- var xy = this.findPos(target);
- evt.clientX = xy[0];
- evt.clientY = xy[1];
- evt.ctrlKey = combo == "CTRL";
- evt.altKey = combo == "ALT";
- evt.metaKey = combo == "META";
- evt.keyCode = charCode;
- evt.shiftKey = isShift; //c.toUpperCase().charCodeAt(0) == evt.charCode;
- evt.shiftLeft = isShift;
- evt.cancelBubble = true;
- target.fireEvent("on" + evType, evt);
- }
- };
-
- Sahi.prototype._setSelected = function (el, val, isMultiple) {
- var l = el.options.length;
- var optionEl = null;
- if (typeof val == "string" || val instanceof RegExp){
- for (var i = 0; i < l; i++) {
- if (this.areEqual(el.options[i], "text", val) ||
- this.areEqual(el.options[i], "id", val)) {
- optionEl = el.options[i];
- }
- }
- } else if (typeof val == "number" && el.options.length > val){
- optionEl = el.options[val];
- }
- if (!optionEl) throw new Error("Option not found: " + val);
-
- for (var i = 0; i < l; i++) {
- if (!isMultiple) el.options[i].selected = false;
- }
-
- optionEl.selected = true;
- this.simulateEvent(el, "change");
- };
-
- // api for set value end
- Sahi.prototype._check = function (el, val) {
- el.checked = val;
- if (el.onclick) el.onclick();
- };
- //Sahi.prototype._reset = function (n, inEl) {
- // var el = this.findElement(n, "reset", "input", inEl);
- // if (el == null) el = this.findElement(n, "reset", "button", inEl);
- // return el;
- //};
- //Sahi.prototype._submit = function (n, inEl) {
- // var el = this.findElement(n, "submit", "input", inEl);
- // if (el == null) el = this.findElement(n, "submit", "button", inEl);
- // return el;
- //};
- Sahi.prototype._wait = function (i, condn) {
- this.setServerVar("waitConditionTime", new Date().valueOf()+i);
- if (condn) {
- this.waitCondition = condn;
- this.setServerVar("waitCondition", condn);
- window.setTimeout("_sahi.cancelWaitCondition()", i);
- }
- else {
- window.setTimeout("_sahi.cancelWaitCondition()", i);
- this.waitInterval = i;
- }
- };
-
- Sahi.prototype.cancelWaitCondition = function (){
- this.waitCondition=null;
- this.waitInterval=this.INTERVAL;
- this.setServerVar("waitCondition", null);
- this.setServerVar("waitConditionTime", -1);
- };
-
- //Sahi.prototype._file = function (n, inEl) {
- // return this.findElement(n, "file", "input", inEl);
- //};
- //Sahi.prototype._password = function (n, inEl) {
- // return this.findElement(n, "password", "input", inEl);
- //};
- //Sahi.prototype._checkbox = function (n, inEl) {
- // return this.findElement(n, "checkbox", "input", inEl);
- //};
- //Sahi.prototype._textarea = function (n, inEl) {
- // return this.findElement(n, "textarea", "textarea", inEl);
- //};
- Sahi.prototype._hidden = function (n, inEl) {
- return this.findElement(n, "hidden", "input", inEl);
- };
- Sahi.prototype._accessor = function (n) {
- return eval(n);
- };
- Sahi.prototype._byId = function (id) {
- return this.findElementById(this.top(), id);
- };
- Sahi.prototype._byText = function (text, tag) {
- var res = this.getBlankResult();
- return this.tagByText(this.top(), text, tag, res).element;
- };
- Sahi.prototype._byClassName = function (className, tagName) {
- var res = this.getBlankResult();
- var el = this.findTagHelper(className, this.top(), tagName, res, "className").element;
- return el;
- };
- //Sahi.prototype._radio = function (n, inEl) {
- // return this.findElement(n, "radio", "input", inEl);
- //};
- //Sahi.prototype._div = function (id, inEl) {
- // return this.spandivcommon(id, inEl, "div");
- //};
- //Sahi.prototype._span = function (id, inEl) {
- // return this.spandivcommon(id, inEl, "span");
- //};
- //Sahi.prototype.spandivcommon = function (id, inEl, tagName) {
- // if (!inEl) inEl = this.top();
- // var res = this.getBlankResult();
- // var el = this.findTagHelper(id, inEl, tagName, res, "id").element;
- // if (el == null) el = this.tagByText(inEl, id, tagName, res).element;
- // return el;
- //};
- Sahi.prototype._spandiv = function (id, inEl) {
- if (!inEl) inEl = this.top();
- var el = this._span(id, inEl);
- if (el == null) el = this._div(id, inEl);
- return el;
- };
- //Sahi.prototype._listItem = function (id) {
- // var res = this.getBlankResult();
- // var el = this.findTagHelper(id, this.top(), "li", res, "id").element;
- // if (el == null) el = this.tagByText(this.top(), id, "li", res).element;
- // return el;
- //};
- //Sahi.prototype._label = function (id) {
- // var res = this.getBlankResult();
- // var el = this.findTagHelper(id, this.top(), "label", res, "id").element;
- // if (el == null) el = this.tagByText(this.top(), id, "label", res).element;
- // return el;
- //};
- Sahi.prototype.tagByText = function (win, id, tagName, res) {
- var o = this.getArrayNameAndIndex(id);
- var ix = o.index;
- var fetch = o.name;
- var els = this.getDoc(win).getElementsByTagName(tagName);
- for (var i = 0; i < els.length; i++) {
- var el = els[i];
- var text = this._getText(el);
-
- if (this.isTextMatch(text, fetch)) {
- res.cnt++;
- if (res.cnt == ix || ix == -1) {
- res.element = this.innerMost(el, id, tagName.toUpperCase());
- res.found = true;
- return res;
- }
- }
- }
- var frs = win.frames;
- if (frs) {
- for (var j = 0; j < frs.length; j++) {
- try{
- res = this.tagByText(frs[j], id, tagName, res);
- }catch(e){}
- if (res && res.found) return res;
- }
- }
- return res;
- };
- Sahi.prototype.isTextMatch = function(sample, pattern){
- if (pattern instanceof RegExp)
- return sample.match(pattern);
- return (sample == pattern);
- };
- Sahi.prototype.innerMost = function(el, re, tagName){
- for (var i=0; i < el.childNodes.length; i++){
- var child = el.childNodes[i];
- var text = this._getText(child);
- if (text && text.match(re)){
- var inner = this.innerMost(child, re, tagName);
- if (inner.nodeName == tagName) return inner;
- }
- }
- return el;
- };
- //Sahi.prototype._image = function (n, inEl) {
- // return this.findImage(n, inEl);
- //};
- //Sahi.prototype._imageSubmitButton = function (n, inEl) {
- // return this.findElement(n, "image", "input", inEl);
- //};
- Sahi.prototype._simulateEvent = function (el, ev) {
- if (this.isIE()) {
- var newFn = (eval("el.on" + ev.type)).toString();
- newFn = newFn.replace("anonymous()", "s_anon(s_ev)", "g").replace("event", "s_ev", "g");
- eval(newFn);
- s_anon(ev);
- } else {
- eval("el.on" + ev.type + "(ev);");
- }
- };
- Sahi.prototype._setGlobal = function (name, value) {
- //this._debug("SET name="+name+" value="+value);
- this.setServerVar(name, value, true);
- };
- Sahi.prototype._getGlobal = function (name) {
- var value = this.getServerVar(name, true);
- //this._debug("GET name="+name+" value="+value);
- return value;
- };
- Sahi.prototype._set = function (name, value) {
- this.locals[name] = value;
- };
- Sahi.prototype._get = function (name) {
- var value = this.locals[name];
- return value;
- };
- Sahi.prototype._assertNotNull = function (n, s) {
- if (n == null) throw new SahiAssertionException(1, s);
- return true;
- };
- Sahi.prototype._assertExists = Sahi.prototype._assertNotNull;
- Sahi.prototype._assertNull = function (n, s) {
- if (n != null) throw new SahiAssertionException(2, s);
- return true;
- };
- Sahi.prototype._assertNotExists = Sahi.prototype._assertNull;
- Sahi.prototype._assertTrue = function (n, s) {
- if (n != true) throw new SahiAssertionException(5, s);
- return true;
- };
- Sahi.prototype._assert = Sahi.prototype._assertTrue;
- Sahi.prototype._assertNotTrue = function (n, s) {
- if (n) throw new SahiAssertionException(6, s);
- return true;
- };
- Sahi.prototype._assertFalse = Sahi.prototype._assertNotTrue;
- Sahi.prototype._assertEqual = function (expected, actual, s) {
- if (this.trim(expected) != this.trim(actual)) throw new SahiAssertionException(3, (s ? s : "") + "\nExpected:[" + expected + "]\nActual:[" + actual + "]");
- return true;
- };
- Sahi.prototype._assertNotEqual = function (expected, actual, s) {
- if (this.trim(expected) == this.trim(actual)) throw new SahiAssertionException(4, s);
- return true;
- };
- Sahi.prototype._assertContainsText = function (expected, el, s) {
- var text = this._getText(el);
- var present = false;
- if (expected instanceof RegExp)
- present = expected != null && text.match(expected) != null;
- else present = text.indexOf(expected) != -1;
- if (!present) throw new SahiAssertionException(3, (s ? s : "") + "\nExpected:[" + expected + "] to be part of [" + text + "]");
- return true;
- };
- Sahi.prototype._getSelectedText = function (el) {
- var opts = el.options;
- for (var i = 0; i < opts.length; i++) {
- if (el.value == opts[i].value) return opts[i].text;
- }
- return null;
- };
- Sahi.prototype._option = function (el, text) {
- var opts = el.options;
- for (var i = 0; i < opts.length; i++) {
- if (text == opts[i].text) return opts[i];
- }
- return null;
- };
- Sahi.prototype._getText = function (el) {
- this.checkNull(el, "_getText");
- return this.trim(this.isIE() || this.isSafariLike() ? el.innerText : el.textContent);
- };
- Sahi.prototype._getCellText = Sahi.prototype._getText;
- Sahi.prototype.getRowIndexWith = function (txt, tableEl) {
- var r = this.getRowWith(txt, tableEl);
- return (r == null) ? -1 : r.rowIndex;
- };
- Sahi.prototype.getRowWith = function (txt, tableEl) {
- for (var i = 0; i < tableEl.rows.length; i++) {
- var r = tableEl.rows[i];
- for (var j = 0; j < r.cells.length; j++) {
- if (this._getText(r.cells[j]).indexOf(txt) != -1) {
- return r;
- }
- }
- }
- return null;
- };
- Sahi.prototype.getColIndexWith = function (txt, tableEl) {
- for (var i = 0; i < tableEl.rows.length; i++) {
- var r = tableEl.rows[i];
- for (var j = 0; j < r.cells.length; j++) {
- if (this._getText(r.cells[j]).indexOf(txt) != -1) {
- return j;
- }
- }
- }
- return -1;
- };
- Sahi.prototype._alert = function (s) {
- return this.callFunction(this.real_alert, window, s);
- };
- Sahi.prototype._lastAlert = function () {
- var v = this.getServerVar("lastAlertText");
- return v;
- };
- Sahi.prototype._eval = function (s) {
- return eval(s);
- };
- Sahi.prototype._call = function (s) {
- return s;
- };
- Sahi.prototype._random = function (n) {
- return Math.floor(Math.random() * (n + 1));
- };
- Sahi.prototype._savedRandom = function (id, min, max) {
- if (min == null) min = 0;
- if (max == null) max = 10000;
- var r = this.getServerVar("srandom" + id);
- if (r == null || r == "") {
- r = min + this._random(max - min);
- this.setServerVar("srandom" + id, r);
- }
- return r;
- };
- Sahi.prototype._resetSavedRandom = function (id) {
- this.setServerVar("srandom" + id, "");
- };
-
-
- Sahi.prototype._expectConfirm = function (text, value) {
- this.setServerVar("confirm: "+text, value);
- };
- Sahi.prototype._saveDownloadedAs = function(filePath){
- this._callServer("SaveAs_saveLastDownloadedAs", "destination="+encodeURIComponent(filePath));
- };
- Sahi.prototype._lastDownloadedFileName = function(){
- var fileName = this._callServer("SaveAs_getLastDownloadedFileName");
- if (fileName == "-1") return null;
- return fileName;
- };
- Sahi.prototype._clearLastDownloadedFileName = function(){
- this._callServer("SaveAs_clearLastDownloadedFileName");
- };
- Sahi.prototype._saveFileAs = function(filePath){
- this._callServer("SaveAs_saveTo", filePath);
- };
- Sahi.prototype.recordStep = function(s){
- this.sendToServer("/_s_/dyn/Recorder2_addRecordedStep?step="+ encodeURIComponent(s));
- };
- Sahi.prototype.callFunction = function(fn, obj, args){
- if (fn.apply){
- return fn.apply(window, [args]);
- }else{
- return fn(args);
- }
- };
- Sahi.prototype._lastConfirm = function () {
- var v = this.getServerVar("lastConfirmText");
- return v;
- };
-
- Sahi.prototype._lastPrompt = function () {
- var v = this.getServerVar("lastPromptText");
- return v;
- };
-
- Sahi.prototype._expectPrompt = function (text, value) {
- this.setServerVar("prompt: "+text, value);
- };
- Sahi.prototype._prompt = function (s) {
- return this.callFunction(this.real_prompt, window, s);
- };
-
- Sahi.prototype._print = function (s){
- return this.callFunction(this.real_print, window, s);
- };
- Sahi.prototype._printCalled = function (){
- return this.getServerVar("printCalled");
- };
- Sahi.prototype._clearPrintCalled = function (){
- this.setServerVar("printCalled", null);
- };
- Sahi.prototype._cell = function (id, row, col) {
- if (id == null) return null;
- if (row == null && col == null) {
- return this.findCell(id);
- }
- if (row != null && (row.type == "_in" || row.type == "_near")){
- return this.findCell(id, row);
- }
-
- var rowIx = row;
- var colIx = col;
- if (typeof row == "string") {
- rowIx = this.getRowIndexWith(row, id);
- if (rowIx == -1) return null;
- }
- if (typeof col == "string") {
- colIx = this.getColIndexWith(col, id);
- if (colIx == -1) return null;
- }
- if (id.rows[rowIx] == null) return null;
- return id.rows[rowIx].cells[colIx];
- };
-
- //Sahi.prototype._table = function (n, inEl) {
- // return this.findTable(n, inEl);
- //};
- Sahi.prototype._row = function (tableEl, rowIx) {
- if (typeof rowIx == "string") {
- return this.getRowWith(rowIx, tableEl);
- }
- if (typeof rowIx == "number") {
- return tableEl.rows[rowIx];
- }
- return null;
- };
- Sahi.prototype._containsHTML = function (el, htm) {
- return el && el.innerHTML && el.innerHTML.indexOf(htm) != -1;
- };
- Sahi.prototype._containsText = function (el, txt) {
- return el && this._getText(el).indexOf(txt) != -1;
- };
- Sahi.prototype._contains = function (parent, child) {
- var c = child;
- while (true){
- if (c == parent) return true;
- if (c == null || c == c.parentNode) return false;
- c = c.parentNode;
- }
- };
- Sahi.prototype._popup = function (n) {
- if (this.top().name == n || this.top().document.title == n) {
- return this.top();
- }
- throw new SahiNotMyWindowException(n);
- };
- Sahi.prototype._log = function (s, type) {
- if (!type) type = "info";
- this.logPlayBack(s, type);
- };
- Sahi.prototype._navigateTo = function (url, force) {
- if (force || this.top().location.href != url)
- this.top().location.href = url;
- // this.top().setTimeout("location.href = '"+url+"'", 1);
- };
- Sahi.prototype._callServer = function (cmd, qs) {
- return this.sendToServer("/_s_/dyn/" + cmd + (qs == null ? "" : ("?" + qs)));
- };
- Sahi.prototype._removeMock = function (pattern) {
- return this._callServer("MockResponder_remove", "pattern=" + pattern);
- };
- Sahi.prototype._addMock = function (pattern, clazz) {
- if (clazz == null) clazz = "MockResponder_simple";
- return this._callServer("MockResponder_add", "pattern=" + pattern + "&class=" + clazz);
- };
- Sahi.prototype._mockImage = function (pattern, clazz) {
- if (clazz == null) clazz = "MockResponder_mockImage";
- return this._callServer("MockResponder_add", "pattern=" + pattern + "&class=" + clazz);
- };
- Sahi.prototype._debug = function (s) {
- return this._callServer("Debug_toOut", "msg=Debug: " + encodeURIComponent(s));
- };
- Sahi.prototype._debugToErr = function (s) {
- return this._callServer("Debug_toErr", "msg=" + encodeURIComponent(s));
- };
- Sahi.prototype._debugToFile = function (s, file) {
- if (file == null) return null;
- return this._callServer("Debug_toFile", "msg=" + encodeURIComponent(s) + "&file=" + encodeURIComponent(file));
- };
- Sahi.prototype._enableKeepAlive = function () {
- this.sendToServer('/_s_/dyn/Configuration_enableKeepAlive');
- };
- Sahi.prototype._disableKeepAlive = function () {
- this.sendToServer('/_s_/dyn/Configuration_disableKeepAlive');
- };
- Sahi.prototype.getWin = function (el) {
- if (el == null) return self;
- if (el.nodeName.indexOf("document") != -1) return this.getFrame1(this.top(), el);
- return this.getWin(el.parentNode);
- };
- // finds window to which a document belongs
- Sahi.prototype.getFrame1 = function (win, doc) {
- if (win.document == doc) return win;
- var frs = win.frames;
- for (var j = 0; j < frs.length; j++) {
- var sub = this.getFrame1(frs[j], doc);
- if (sub != null) {
- return sub;
- }
- }
- return null;
- };
-
- Sahi.prototype.simulateChange = function (el) {
- if (window.document.all) {
- if (el.onchange) el.onchange();
- if (el.onblur) el.onblur();
- } else {
- if (el.onblur) el.onblur();
- if (el.onchange) el.onchange();
- }
- };
- Sahi.prototype.areEqual2 = function (el, param, value) {
- if (param == "sahiText") {
- var str = this._getText(el);
- if (value instanceof RegExp)
- return str != null && str.match(value) != null;
- return (this.trim(str) == this.trim(value));
- }
- else {
- if (value instanceof RegExp)
- return el[param] != null && el[param].match(value) != null;
- return (el[param] == value);
- }
- };
- Sahi.prototype.areEqual = function (el, param, value) {
- if (typeof param == "function"){
- return this.callFunction(param, this, el) == value;
- }
- if (param == null || param.indexOf("|") == -1)
- return this.areEqual2(el, param, value);
- var params = param.split("|");
- for (var i=0; i<params.length; i++){
- if (this.areEqual2(el, params[i], value)) return true;
- }
- return false;
- };
- Sahi.prototype.findElementById = function (win, id) {
- var res = null;
- if (win.document.getElementById(id) != null) {
- return win.document.getElementById(id);
- }
- var frs = win.frames;
- if (frs) {
- for (var j = 0; j < frs.length; j++) {
- try{
- res = this.findElementById(frs[j], id);
- }catch(diffDomain){}
- if (res) return res;
- }
- }
- return res;
- };
- Sahi.prototype.findFormElementByIndex = function (ix, win, type, res, tagName) {
- var els = this.getDoc(win).getElementsByTagName(tagName);
- for (var j = 0; j < els.length; j++) {
- var el = els[j];
- if (el != null && this.areEqualTypes(el.type, type)) {
- res.cnt++;
- if (res.cnt == ix) {
- res.element = el;
- res.found = true;
- return res;
- }
- }
- }
- var frs = win.frames;
- if (frs) {
- for (var k = 0; k < frs.length; k++) {
- try{
- res = this.findFormElementByIndex(ix, frs[k], type, res, tagName);
- }catch(e){}
- if (res && res.found) return res;
- }
- }
- return res;
- };
-
- Sahi.prototype.findElementHelper = function (id, win, type, res, param, tagName) {
- if ((typeof id) == "number") {
- res = this.findFormElementByIndex(id, win, type, res, tagName);
- if (res.found) return res;
- } else {
- var doc = this.getDoc(win);
- var els = doc.getElementsByTagName(tagName);
- for (var j = 0; j < els.length; j++) {
- if (this.areEqualTypes(els[j].type, type) && this.areEqual(els[j], param, id)) {
- res.element = els[j];
- res.found = true;
- return res;
- }
- }
-
- var o = this.getArrayNameAndIndex(id);
- var ix = o.index;
- var fetch = o.name;
- els = this.getDoc(win).getElementsByTagName(tagName);
- for (var k = 0; k < els.length; k++) {
- if (this.areEqualTypes(els[k].type, type) && this.areEqual(els[k], param, fetch)) {
- res.cnt++;
- if (res.cnt == ix || ix == -1) {
- res.element = els[k];
- res.found = true;
- return res;
- }
- }
- }
-
-
- }
- var frs = win.frames;
- if (frs) {
- for (var ii = 0; ii < frs.length; ii++) {
- try{
- res = this.findElementHelper(id, frs[ii], type, res, param, tagName);
- }catch(e){}
- if (res && res.found) return res;
- }
- }
- return res;
- };
- Sahi.prototype.findElementIxHelper = function (id, type, toMatch, win, res, param, tagName) {
- if (res && res.found) return res;
- var els = win.document.getElementsByTagName(tagName);
- for (var j = 0; j < els.length; j++) {
- if (this.areEqualTypes(els[j].type, type) && this.areEqual(els[j], param, id)) {
- res.cnt++;
- if (els[j] == toMatch) {
- res.found = true;
- return res;
- }
- }
- }
- var frs = win.frames;
- if (frs) {
- for (var k = 0; k < frs.length; k++) {
- try{
- res = this.findElementIxHelper(id, type, toMatch, frs[k], res, param, tagName);
- }catch(e){};
- if (res && res.found) return res;
- }
- }
- return res;
- };
- Sahi.prototype.areEqualTypes = function (type1, type2) {
- if (type1 == type2) return true;
- return (type1.indexOf("select") != -1 && type2.indexOf("select") != -1);
- };
- Sahi.prototype.findCell = function (id, inEl) {
- if (!inEl) inEl = this.top();
- var res = this.getBlankResult();
- res = this.findTagHelper(id, inEl, "td", res, "id").element;
- if (res != null) return res;
- res = this.getBlankResult();
- return this.findTagHelper(id, inEl, "td", res, "sahiText").element;
- };
-
- Sahi.prototype.findCellIx = function (id, toMatch, attr) {
- var res = this.getBlankResult();
- var retVal = this.findTagIxHelper(id, toMatch, this.top(), "td", res, attr).cnt;
- if (retVal != -1) return retVal;
- };
- Sahi.prototype.getBlankResult = function () {
- var res = new Object();
- res.cnt = -1;
- res.found = false;
- res.element = null;
- return res;
- };
-
- Sahi.prototype.getArrayNameAndIndex = function (id) {
- var o = new Object();
- if (!(id instanceof RegExp) && id.match(/(.*)\[([0-9]*)\]$/)) {
- o.name = RegExp.$1;
- o.index = parseInt(RegExp.$2);
- } else {
- o.name = id;
- o.index = -1;
- }
- return o;
- };
- Sahi.prototype.findTableIx = function (id, toMatch) {
- var res = this.getBlankResult();
- var retVal = this.findTagIxHelper(id, toMatch, this.top(), "table", res, (id ? "id" : null)).cnt;
- if (retVal != -1) return retVal;
- };
-
- Sahi.pr…
Large files files are truncated, but you can click here to view the full file