Hi Mauro,

     Thank you for follow up.

      I just resolved this by using Java reflection to get the step string
value.

      But..., I have another more important issue need to figure out: My
boss asked me to develop a *"Visual" GUI style* BDD function, which uses
javascript alert/confirm popup window to prompt user what is the exact step
the running test reaches, eg:

                 Given I goto "www.a.com"
                 When I login

        So we want to add *Javascript alert window to popup during the
automation test*, the popped up window has the "OK" button, so when user
click the OK button, the test will continue to the next step, and so on...

         My issue is: I wrote a javascript func using Selenium's *executeScript
*API which invoke the pop up alert window:

               *public void stepText(String step){*
*       executeScript("alert('"+step+"');");*
*        }*

           So I expect when I click the OK button, the popped up window
will disappear and test will continue to next step... *But what shocked me
is that when I click it, the test throw exception and crashed...*
*
*
            The exception is: selenium.WebDriverException

            But I found if I add the following code to make the test
automatically detect the alert window and accept it by using the following
usual selenium alert handle function:

                   *Alert alert=switchTo().alert();*
*                   alert.accept();*

             This can make the test runs well, so it looks *I can NOT
manually click the alert (after I manually click, the selenium still can
NOT go back to the browser...lost connection to browser?), but the
automation alert handle code works...*

              Of course, *we want to let user to manually to click alert
window to control the test execution, not the automation handle alert*.

               I really got stuck here for a while, and did a lot googling
to search, but can not find similar example online, I hope you can shed me
light on it, since you are much more guru than me on JBehave and Selenium.

               I will be much grateful if you can help me out.

Kind Regards,

Brian

On Mon, Jun 10, 2013 at 1:02 PM, Mauro Talevi <[email protected]>wrote:

>  Hi,
>
> if this is the case you're better off implementing a StepMonitor.
>
> You may want to have a look at the SeleniumStepMonitor in the
> jbehave-web-selenium module, which uses a ContextView to broadcast the step
> being executed.
>
> You can adapt it to your usecase.
>
> Cheers
>
>
> On 10/06/2013 16:44, Jie Zhang wrote:
>
> Hi Mauro,
>
>       Thanks for follow up. But my goal is not to output to the default
> html/text report page, I need to get the step string (as a var) value, then
> I can print it on javascript alert window.
>
>        I see the StoryReporter.successful(String step) just print the
> step str on the default report page, and its return type is void, so how
> can I get the step str value?
>
>        I'm not sure if I explained my stuck clearly to you, if my
> understanding is wrong, pls correct me, thank you very much and waiting for
> your help out.
>
>  Kind Regards,
>
>  -- Brian
>
> On Sat, Jun 8, 2013 at 7:55 AM, Mauro Talevi 
> <[email protected]>wrote:
>
>>  That's what the StoryReporter does.
>>
>> In particular,  StoryReporter.successful(String step) will provide you
>> the successful step that's just been executed.
>>
>> Have a look at CustomHtmlOutput in the jbehave-core-example for an
>> example of how to setup a custom reporter.
>>
>> Cheers
>>
>>
>> On 07/06/2013 21:20, Jie Zhang wrote:
>>
>> Hi Mauro,
>>
>>       I got a mission to finish by using JBehave.
>>
>>       Do you know how I can get the "step" 's name (its context/text) so
>> I can print it. Eg:
>>
>>                  *Given I goto 'www.google.com'*
>>
>>        So what I want is I can get the "*I goto 'www.google.com'*" text
>> value, so I can print it.
>>
>>         Is there a JBehave API, class, method that we can use to do this
>> task?
>>
>>         Thank you and very appreciated if you can help me out!
>>
>>  Brian
>>
>>
>>
>
>

Reply via email to