refactoror / SelBlocks

SelBlocks extension for Selenium IDE
10 stars 7 forks source link

Is it at all possible to add SelBlocks as user-extensions.js to selenium-server? #10

Closed TomaszDom closed 9 years ago

TomaszDom commented 10 years ago

I've tried adding all the *.js scripts to selenium server, but the server freezes when it tries running htmlsuites interactively or otherwise. Is it all possible to add these scripts to selenium server to make a custom build that supports all this new wonderful functionality? Testing in Selenium IDE is one thing, but it would be fantastic to be able to run using the server (and automate using Jenkins, etc.)

refactoror commented 10 years ago

Selblocks is not supported for use in Selenium Server.

All of the languages that are directly supported by Selenium Server, (Java, Python, Ruby, etc), already have the kind of conditional constructs that Selblocks adds to Selenese. The intention is that you would use the language translator for one of those in order to run your scripts in the server.

See the following excerpt from the documentation: "Note that there is no language translation for SelBlock commands, so they're commented-out in exported test scripts. Although hand-translation in the target language ought to be pretty straightforward. I would just say, use these constructs judiciously."

http://refactoror.wikia.com/wiki/Selblocks_Reference#Philosophical_Note

TomaszDom commented 10 years ago

In my experience, the language translators never work exactly as they should. The second thing is that it's much much easier for non-programmers to use the IDE and Selblocks to actually produce great tests without having to learn a single bit of coding, only some new logic. This lowers the barrier to entry tremendously. There is no other product like it.

"But in practice I am able to maintain MUCH simpler scripts by using some if/else and looping" - yes, yes a thousand times.

How difficult for a Java/JS programmmer would it be to adapt these scripts to run on the server?

refactoror commented 10 years ago

My understanding of Selenium Server is that it sends Javascript snippets to the browser(s), which then interact with the webpage. Note that the actual sequencing and sending of those commands is driven by the server, which can be in any language that has a binding for the Selenium Server API. However, Selenese is not one of those languages, hence language translators.

The reality is, to run any Selenese script on Selenium Server, it must first be translated into one of the supported languages. If Selblocks commands are being used, then those need to be translated as well.

Unfortunately, I just don't have the bandwidth to work on the translator side of things. The good thing is that translators are independent components, and do not require internal knowledge of Selenese, nor of the target language.

Perhaps there is another interested member of the community out there...

matthewkastor commented 9 years ago

The command line switch -htmlSuite runs the test suites created with Selenium IDE on the Selenium Server. Adding a couple more switches turns on abilities to test in other browsers and log results. Having the ability to add selblocks as user extension on the server would be awesome. I see someone posted their work online at http://www.onsreg.org/home/sel-blks-1-3-under-selenium-server-2-25 that says it is an older version of selblocks adapted to an older version of the selenium server.

java -jar selenium-server-standalone-2.43.1 -Dwebdriver.ie.driver=IEDriverServer.exe -Dwebdriver.chrome.driver=chromedriver.exe -htmlSuite "*firefox" "http://www.google.com" "C:\seleniumTestSuites\Test_Suite.html" "C:\SeleniumTestResults\results.html" -log "C:\SeleniumLogs\Selenium Server Log.txt" -browserSideLog -userExtensions "C:\SeleniumServerUserExtensions\user-extensions.js"

The htmlSuite option is described on this page: http://www.seleniumhq.org/docs/05_selenium_rc.jsp#server-options

Writing and using user extensions for both selenium ide and the server is detailed on this page: http://www.seleniumhq.org/docs/08_user_extensions.jsp

refactoror commented 9 years ago

So that's great. Although, it looks like the -userExtensions option can specify only single .js file, whereas SelBlocks consists of several .js files. What you could try is unzipping sel-blocks-fx.xpi, and then concatenate together the .js files located in the chrome/content/extensions directory. Note that the files would need to be in the same order as they are listed in extension-loader.xul.

This might work as long as the target browser is Firefox. However, I would be surprised if it worked without issues for other browsers, since SelBlocks code has never been tested with the JavaScript implementation of any other browser.

matthewkastor commented 9 years ago

I will try that after I eat dinner and let you know if it works the "function" command. On Dec 14, 2014 3:30 PM, "refactoror" notifications@github.com wrote:

So that's great. Although, it looks like the -userExtensions option can specify only single .js file, whereas SelBlocks consists of several .js files. What you could try is unzipping sel-blocks-fx.xpi, and then concatenate together the .js files located in the chrome/content/extensions directory. Note that the files would need to be in the same order as they are listed in extension-loader.xul.

This might work as long as the target browser is Firefox. However, I would be surprised if it worked without issues for other browsers, since SelBlocks code has never been tested with the JavaScript implementation of any other browser.

— Reply to this email directly or view it on GitHub https://github.com/refactoror/SelBlocks/issues/10#issuecomment-66928274.

matthewkastor commented 9 years ago

I tried putting all the files together in the order you said to, but it errors out when compileSelBlocks is called. It says that testCase is undefined. I've got a test suite loaded and the cases show up, but I don't know where this function is supposed to find testCase.

  // ================================================================================
  // Assemble block relationships and symbol locations
  function compileSelBlocks()
  {
    blockDefs = new BlockDefs();
    var lexStack = new Stack();
    var i;

    for (i = 0; i < testCase.commands.length; i++)
    {
      if (testCase.commands[i].type === "command")

I combined all the files using:

copy "name-space.js"+"logger.js"+"function-intercepting.js"+"xpath-processing.js"+"expression-parser.js"+"selenium-executionloop-handleAsExitTest.js"+"selenium-executionloop-handleAsTryBlock.js"+"selblocks.js" /B user-extensions.js /B
refactoror commented 9 years ago

The testCase object is one of the fundamental objects in Selenium IDE, and SelBlocks works by extending it. If it is not present in Selenium Server, then extending Selenese would work differently in that context, if at all.

matthewkastor commented 9 years ago

I've got some time off. I'll look into it a bit more over the next few days. On Dec 15, 2014 12:13 PM, "refactoror" notifications@github.com wrote:

The testCase object is one of the fundamental objects in Selenium IDE, and SelBlocks works by extending it. If it is not present in Selenium Server, then extending Selenese would work differently in that context, if at all.

— Reply to this email directly or view it on GitHub https://github.com/refactoror/SelBlocks/issues/10#issuecomment-67028848.

matthewkastor commented 9 years ago

I've got it working. I didn't test it a lot, just a couple simple cases that use an "if" and a "function". I'll make a pull request soon. On Dec 15, 2014 7:18 PM, "Matthew Kastor" matthewkastor@gmail.com wrote:

I've got some time off. I'll look into it a bit more over the next few days. On Dec 15, 2014 12:13 PM, "refactoror" notifications@github.com wrote:

The testCase object is one of the fundamental objects in Selenium IDE, and SelBlocks works by extending it. If it is not present in Selenium Server, then extending Selenese would work differently in that context, if at all.

— Reply to this email directly or view it on GitHub https://github.com/refactoror/SelBlocks/issues/10#issuecomment-67028848 .

matthewkastor commented 9 years ago

Submitted https://github.com/refactoror/SelBlocks/pull/13 it works but you've probably got some good tests to run it through. XD

refactoror commented 9 years ago

SelBlocks 2.1 introduces support for Selenium Server. Get the extension file here: https://raw.githubusercontent.com/refactoror/SelBlocks/master/user-extensions.js

Initial browser support is for firefox, googlechrome, and opera.

reegen commented 7 years ago

Hi,

I saw in your Wiki (http://refactoror.wikia.com/wiki/Selblocks_Reference) that you posted that "this feature has a significant bug, and is not currently supported.":

image

Is it still with the bug, or you already fixed it?