18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

How to Cancel 2nd confirm?

HanKosterHanKoster Members
edited August 2013 in Sahi - Open Source
I am testing a webpage that asks two questions when I click on a button.
The first one I want to click OK, the second one Cancel.
I tried the following:

_expectConfirm("First question", true);
_expectConfirm("Second question", false);
_click(_submit("Go"));

When the script continues, the contents of the page are as if both questions have been answered OK.

I tried the same without the _expectConfirm("First question", true); as the default handling of confirmation boxes is to click OK. But also now the page contents is as if both questions have been answered OK.

What am I doing wrong?

Answers

  • Hi HanKoster,
    First of all let me ask you what version of Sahi OS are you using?
    If it is not Sahi OS 4.4, please upgrade to the same.

    In Sahi OS 4.4, I created a test page and script and it works properly.

    If you are using v4.4, please check if the first parameter in _expectConfirm is exactly the same as the text in your confirm boxes.

    I am attaching the code of my test page and script. You can check it out on your end.

    The HTML page code:
    <HTML>
    <head>
    <title>Temp</title>
    </head>
    <body>
    <input type="text" id="t1">
    <input type="button" id="b1" onclick="openConfirms()">
    <script>
    openConfirms = function(){
    	var confirm = window.confirm("first");
    	if(confirm){
    		document.getElementById("t1").value = document.getElementById("t1").value + "true";
    	}else{
    		document.getElementById("t1").value = document.getElementById("t1").value + "false";
    	}
    	var confirm2 = window.confirm("second");
    	if(confirm2){
    		document.getElementById("t1").value = document.getElementById("t1").value + " true";
    	}else{
    		document.getElementById("t1").value = document.getElementById("t1").value + " false";
    	}
    }
    </script>
    </body>
    </HTML>
    

    The script i run on it:
    _expectConfirm("first", true);
    _expectConfirm("second", false);
    _click(_button("b1"));
    _assertEqual("true false", _getValue(_textbox("t1")));
    

    Regards.
  • I have no access to the webserver, so I am not able to run your test page. I am testing a system that is being developped for us.
    So I have to do the testing by hand, write down what I see and program that in the testscript.
    As far as I can see, I copied the text from the confirm boxes exactly.
    The sahi version I am running is generated from sahi_20130206.zip
    I checked the info page of the Sahi Controller and is says 4.3
    I'll try to get and install version 4.4 and will report back later.
  • Alas, Version 4.4 is not working.
    Because the web page is different as I expect, the script stops with a FAILURE.
    When I click "View Logs" on the controller window a new tab opens on http://www.mysite.com/_s_/dyn/Log_viewLogs. That page says SAHI_ERROR
    And when I look in the folder .../sahi/userdata/logs it is empty!
  • Additional information of the error:
    I am running a Dutch computer.
    Translation of errors:
    1. Het systeem kan het opgegeven pad niet vinden
    = The system cannot find the given path
    2. Toegang geweigerd
    = Access denied
    When I start sahi.bat from the bin directory it says:
    SAHI_HOME: ..
    SAHI_USERDATA_DIR: ..\userdata
    SAHI_EXT_CLASS_PATH:
    Sahi properties file = C:\Program Files\sahi\config\sahi.properties
    Sahi user properties file = C:\Program Files\sahi\userdata\config\userdata.prope
    rties
    java.io.IOException: Het systeem kan het opgegeven pad niet vinden
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at net.sf.sahi.util.FileUtils.copyFile(FileUtils.java:60)
    at net.sf.sahi.util.FileUtils.copyDir(FileUtils.java:42)
    at net.sf.sahi.util.FileUtils.copyDir(FileUtils.java:29)
    at net.sf.sahi.config.Configuration.copyProfiles(Configuration.java:175)

    at net.sf.sahi.config.Configuration.init(Configuration.java:107)
    at net.sf.sahi.Proxy.main(Proxy.java:76)
    Added shutdown hook.
    >>>> Sahi started. Listening on port: 9999
    >>>> Configure your browser to use this server and port as its proxy
    >>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Cont
    roller
    java.io.IOException: Toegang geweigerd
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at net.sf.sahi.util.FileUtils.copyFile(FileUtils.java:60)
    at net.sf.sahi.util.FileUtils.copyFile(FileUtils.java:48)
    at net.sf.sahi.util.BrowserTypesLoader.getBrowserTypesFilePath(BrowserTy
    pesLoader.java:57)
    at net.sf.sahi.util.BrowserTypesLoader.loadBrowserTypes(BrowserTypesLoad
    er.java:33)
    at net.sf.sahi.util.BrowserTypesLoader.<clinit>(BrowserTypesLoader.java:
    26)
    at net.sf.sahi.Proxy.startProxy(Proxy.java:167)
    at net.sf.sahi.Proxy.start(Proxy.java:117)
    at net.sf.sahi.Proxy.main(Proxy.java:89)
    java.io.FileNotFoundException: C:\Program Files\sahi\userdata\config\browser_typ
    es.xml (Het systeem kan het opgegeven bestand niet vinden)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown So
    urce)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrent
    Entity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineD
    ocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
    nknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U
    nknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So
    urce)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown So
    urce)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unk
    nown Source)
    at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
    at net.sf.sahi.util.BrowserTypesLoader.loadBrowserTypes(BrowserTypesLoad
    er.java:33)
    at net.sf.sahi.util.BrowserTypesLoader.<clinit>(BrowserTypesLoader.java:
    26)
    at net.sf.sahi.Proxy.startProxy(Proxy.java:167)
    at net.sf.sahi.Proxy.start(Proxy.java:117)
    at net.sf.sahi.Proxy.main(Proxy.java:89)
    java.io.IOException: Toegang geweigerd
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at net.sf.sahi.util.FileUtils.copyFile(FileUtils.java:60)
    at net.sf.sahi.util.FileUtils.copyFile(FileUtils.java:48)
    at net.sf.sahi.util.BrowserTypesLoader.getBrowserTypesFilePath(BrowserTy
    pesLoader.java:57)
    at net.sf.sahi.util.BrowserTypesLoader.getAvailableBrowserTypes(BrowserT
    ypesLoader.java:86)
    at net.sf.sahi.Proxy.startProxy(Proxy.java:167)
    at net.sf.sahi.Proxy.start(Proxy.java:117)
    at net.sf.sahi.Proxy.main(Proxy.java:89)
    Reading browser types from: C:\Program Files\sahi\userdata\config\browser_types.
    xml
Sign In or Register to comment.