Git Product home page Git Product logo

Comments (13)

fhoeben avatar fhoeben commented on May 24, 2024

I would like to help, but I have to know more about what your doing and the site.

Are you experiencing 2 problems (with an alert and another with file upload), or do you mean you get a 'file upload dialog' and are unable to select a file and then close the dialog?

Are you testing a public site, can I access it also? Can you give me some steps to reproduce your problem?

from hsac-fitnesse-fixtures.

sadepu12 avatar sadepu12 commented on May 24, 2024

TestCase:

| script | browser test |
| open | http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_confirm |
| wait for visible | Result: |
| show | take screenshot | 1 |
| click | Try it |
| confirm alert |

| show | take screenshot | 2 |

SuiteSetUp

This set up page is executed once, before any tests in this suite.
In it we configure which Java packages contain the logic for our fixtures, which browser we want to use for Selenium tests and we start this browser.
This means we do not have to do this in every test, which means easier maintenance and better performance.

Stopping the browser is done in SuiteTearDown, which is done after all tests in this suite are completed.

!***> Fixture code locations

!include -c .HsacExamples.SlimTests.SuiteSetUp
| Import |
| nl.hsac.fitnesse.fixture.slim.web |

*!
The Selenium configuration below uses lines starting with ''| note'' to have configuration values present that are not currently used.'' |

This allows us to switch to another browser by just adding | note'' to one line and removing it from another, instead of typing the entire line.'' |

''

Furthermore this configuration is prepared for both running the browser on the same (development) machine running Fitnesse (with ''start driver for''), as remotely on a node in a Selenium Grid (with ''connect to driver for'').
The latter allows tests to be executed on different operating systems. This is also very useful to run tests as part of a continuous integration server (i.e. build server), when no browsers are installed on the server running the tests.

!define GRID_HUB {http://remote-selenium.local:4444/wd/hub}
| script | selenium driver setup |
| note | start driver for | chrome |
| note | start driver for | internet explorer |
| note | start driver for | firefox |
| note | start driver for | safari |
| start driver for | phantomjs |
| note | connect to driver for | chrome | at | ${GRID_HUB} |
| note | connect to driver for | internet explorer | at | ${GRID_HUB} |
| note | connect to driver for | firefox | at | ${GRID_HUB} |
| note | connect to driver at | ${GRID_HUB} | with capabilities | !{browserName:internet explorer,platform:Windows 8.1,version:11} |
| note | connect to driver at | ${GRID_HUB} | with json capabilities | {aut:"io.selendroid.testapp", emulator: true} |
| show | driver description |

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

This page seems to use iframes quite a bit, maybe that is causing the problem?

When I run the test you provide I don't see an alert pop-up, which makes not being able to confirm it make sense. When I go to the page manually I do see it. Do you see the alert during test execution?

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

The issue was indeed with the iframes. The 'click Try it' was actually clicking in the textarea with the source. It works when I change the test to (notice the explicit 'switch to frame'):

|script         |browser test                                                      |
|open           |http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_confirm|
|switch to frame|id=iframeResult                                                   |
|click          |Try it                                                            |
|check          |alert text                       |Press a button!                 |
|confirm alert                                                                     |
|show           |take screenshot                  |2                               |

from hsac-fitnesse-fixtures.

sadepu12 avatar sadepu12 commented on May 24, 2024

actually when click "Delete Record" button, it's call javascript alert message ('Are you sure you want to delete record: '+primKey+'?')) and title is 'message from webpage' with OK and Cancel button.
and getting below errors.. for the

|check |alert text |Are you sure you want to delete record: 5602466? |
| confirm alert |

");

function bewisrAjaxSaveRecord(type,primKey,category,description)
{
bewisrAjaxSaveRecordType = type;
bewisrAjaxSaveRecordPrimKey=primKey;

if(type=='delete')
{
if(confirm('Are you sure you want to delete record: '+primKey+'?'))
{
bewisrAjaxSaveRecordXmlHttp= new vMInitXMLHttpRequest();

var url="/theDesk/vManager/servlet/BewisrCtrl?request_view=bewisrSetRpt&requestType=bewisrUpdateRec&description="+escape(description)+"&category="+escape(category)+"&type="+escape(type)+"&primKey="+escape(primKey);

bewisrAjaxSaveRecordXmlHttp.onreadystatechange=bewisrAjaxSaveRecordStateChanged;
bewisrAjaxSaveRecordXmlHttp.open("GET",url,true);
bewisrAjaxSaveRecordXmlHttp.send(null);

return;
}

|check |alert text |Are you sure you want to delete record: 5602466? |

org.openqa.selenium.UnsupportedCommandException: Invalid Command Method - {"headers":{"Accept-Encoding":"gzip,deflate","Cache-Control":"no-cache","Connection":"Keep-Alive","Host":"localhost:14149","User-Agent":"Apache-HttpClient/4.3.6 (java 1.5)"},"httpVersion":"1.1","method":"GET","url":"/alert_text","urlParsed":{"anchor":"","query":"","file":"alert_text","directory":"/","path":"/alert_text","relative":"/alert_text","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/alert_text","queryKey":{},"chunks":["alert_text"]},"urlOriginal":"/session/239e4560-8aef-11e5-9843-e3e3f1d45cc0/alert_text"}
Command duration or timeout: 10 milliseconds
Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44'
System info: host: 'W7E1377158', ip: '172.26.24.229', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_75'
Session ID: 239e4560-8aef-11e5-9843-e3e3f1d45cc0
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{platform=XP, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, driverVersion=1.2.0, locationContextEnabled=false, version=2.0.0, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=false, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, webStorageEnabled=false, driverName=ghostdriver, applicationCacheEnabled=false, takesScreenshot=true}]
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.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:912)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper.getAlert(SeleniumHelper.java:962)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.getAlert(BrowserTest.java:247)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.alertText(BrowserTest.java:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81)
at nl.hsac.fitnesse.fixture.slim.SlimFixture.invoke(SlimFixture.java:48)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.superInvoke(BrowserTest.java:100)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest$1.apply(BrowserTest.java:67)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest$1.apply(BrowserTest.java:63)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper$2.apply(SeleniumHelper.java:765)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper$2.apply(SeleniumHelper.java:761)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper.waitUntil(SeleniumHelper.java:750)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.waitUntilImpl(BrowserTest.java:1301)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.waitUntilOrNull(BrowserTest.java:1294)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.invokedWrappedInWaitUntil(BrowserTest.java:86)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.invoke(BrowserTest.java:57)
at nl.hsac.fitnesse.fixture.slim.SlimFixture.aroundSlimInvoke(SlimFixture.java:28)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81)
at fitnesse.slim.MethodExecutor.callMethod(MethodExecutor.java:55)
at fitnesse.slim.MethodExecutor.invokeMethod(MethodExecutor.java:38)
at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:72)
at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:20)
at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:126)
at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:104)
at fitnesse.slim.instructions.CallInstruction.executeInternal(CallInstruction.java:35)
at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29)
at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49)
at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43)
at fitnesse.slim.ListExecutor.execute(ListExecutor.java:83)
at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:87)
at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:80)
at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:58)
at fitnesse.slim.SlimServer.serve(SlimServer.java:43)
at fitnesse.slim.SlimService.handle(SlimService.java:186)
at fitnesse.slim.SlimService.acceptOne(SlimService.java:194)
at fitnesse.slim.SlimService.accept(SlimService.java:156)
at fitnesse.slim.SlimService.startWithFactory(SlimService.java:77)
at fitnesse.slim.SlimService.main(SlimService.java:57)

| confirm alert |

org.openqa.selenium.UnsupportedCommandException: Invalid Command Method - {"headers":{"Accept-Encoding":"gzip,deflate","Cache-Control":"no-cache","Connection":"Keep-Alive","Host":"localhost:14149","User-Agent":"Apache-HttpClient/4.3.6 (java 1.5)"},"httpVersion":"1.1","method":"GET","url":"/alert_text","urlParsed":{"anchor":"","query":"","file":"alert_text","directory":"/","path":"/alert_text","relative":"/alert_text","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/alert_text","queryKey":{},"chunks":["alert_text"]},"urlOriginal":"/session/239e4560-8aef-11e5-9843-e3e3f1d45cc0/alert_text"}
Command duration or timeout: 7 milliseconds
Build info: version: '2.47.1', revision: 'unknown', time: '2015-07-30 11:02:44'
System info: host: 'W7E1377158', ip: '172.26.24.229', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_75'
Session ID: 239e4560-8aef-11e5-9843-e3e3f1d45cc0
Driver info: org.openqa.selenium.phantomjs.PhantomJSDriver
Capabilities [{platform=XP, acceptSslCerts=false, javascriptEnabled=true, browserName=phantomjs, rotatable=false, driverVersion=1.2.0, locationContextEnabled=false, version=2.0.0, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=false, browserConnectionEnabled=false, proxy={proxyType=direct}, nativeEvents=true, webStorageEnabled=false, driverName=ghostdriver, applicationCacheEnabled=false, takesScreenshot=true}]
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.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:912)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper.getAlert(SeleniumHelper.java:962)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.getAlert(BrowserTest.java:247)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.confirmAlert(BrowserTest.java:226)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81)
at nl.hsac.fitnesse.fixture.slim.SlimFixture.invoke(SlimFixture.java:48)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.superInvoke(BrowserTest.java:100)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest$1.apply(BrowserTest.java:67)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest$1.apply(BrowserTest.java:63)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper$2.apply(SeleniumHelper.java:765)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper$2.apply(SeleniumHelper.java:761)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
at nl.hsac.fitnesse.fixture.util.SeleniumHelper.waitUntil(SeleniumHelper.java:750)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.waitUntilImpl(BrowserTest.java:1301)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.waitUntil(BrowserTest.java:1260)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.invokedWrappedInWaitUntil(BrowserTest.java:93)
at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.invoke(BrowserTest.java:57)
at nl.hsac.fitnesse.fixture.slim.SlimFixture.aroundSlimInvoke(SlimFixture.java:28)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:81)
at fitnesse.slim.MethodExecutor.callMethod(MethodExecutor.java:55)
at fitnesse.slim.MethodExecutor.invokeMethod(MethodExecutor.java:38)
at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:72)
at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:20)
at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:126)
at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:104)
at fitnesse.slim.instructions.CallInstruction.executeInternal(CallInstruction.java:35)
at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29)
at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49)
at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43)
at fitnesse.slim.ListExecutor.execute(ListExecutor.java:83)
at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:87)
at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:80)
at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:58)
at fitnesse.slim.SlimServer.serve(SlimServer.java:43)
at fitnesse.slim.SlimService.handle(SlimService.java:186)
at fitnesse.slim.SlimService.acceptOne(SlimService.java:194)
at fitnesse.slim.SlimService.accept(SlimService.java:156)
at fitnesse.slim.SlimService.startWithFactory(SlimService.java:77)
at fitnesse.slim.SlimService.main(SlimService.java:57)

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

try it with a real browser phantomjs' selenium driver does not seem to support alerts

from hsac-fitnesse-fixtures.

sadepu12 avatar sadepu12 commented on May 24, 2024

i completed all my test cases except alert & file upload, i have to use headless browser.
please provide me workaround so that i can complete my UAT testing

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

I'm not aware of any headless solution for dealing with alerts. As far as I'm aware phantomjs just does not support them. I think you just have to test them with a real browser (which I recommend anyways as no user will visit your site with phantom), or test manually. If you do find a workaround: let me know.

What's the problem you face with file uploads? You mentioned this in the original issue, but never gave any details. For me this works without problems.

from hsac-fitnesse-fixtures.

sadepu12 avatar sadepu12 commented on May 24, 2024

alert and file upload functions working with Firefox /chrome browser.
but my requirement is Headless browser (PhantomJs).
i am using..
select file | file| for|input|
it's hanging, not getting timed out/ errors.
please suggest me how to can configure any other Headless browser that support above 2 functions?

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

Like I said before: I'm not aware of any headless solution for alert handling tests.

I'll have to look into the file upload function. I have not tried that with phantom.

May I ask: why the requirement for headless? That's not what real users will do, I suspect.
I'm afraid I will not be able to make this possible for you.

from hsac-fitnesse-fixtures.

sadepu12 avatar sadepu12 commented on May 24, 2024

please try file upload function with phantom.
i run your test case (AlertHandlingTest) with phantomJS still same issue.
Alert & file upload are main modules in any web-application.
in Linux box we will gone use headless browser. that is the requirement
is it possible to use IE or Firefox browsers in Linux machine to test ??
can i use custom mock java-script (Alert & file upload) in the Testcase ??
let me know your inputs please.

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

I just checked file upload element handling. I see no problem selecting files for these (see the test I added as page HsacAcceptanceTests.SlimTests.BrowserTest.FileUploadTest)

Regarding alter handling by phantomJs: if you need that you must request that at PhantomJs project. That's not something I work on.

My suggestion to you is to test with a real browser (running on a different machine, or virtual machine) using Selenium's 'grid' feature. There are also multiple cloud services offering virtual machines with browsers (e.g. BrowserStack or SauceLabs).

from hsac-fitnesse-fixtures.

fhoeben avatar fhoeben commented on May 24, 2024

Using TravisCI to run a Linux PhantomJs test it seems that using file upload input causes problems. It appears phantomJs just crashes when the file upload is used (it might be ariya/phantomjs#10993 or https://github.com/detro/ghostdriver/issues/282). This issue does not occur with phantomJs on OSX.

I have not investigated this further, but again I recommend you: test with a real browser (or actually multiple browsers) to verify the behavior as your real users will see it. PhantomJs is a convenient tool in some circumstances, but it is a different browser (with its own issues) than your users will use.

from hsac-fitnesse-fixtures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.