I got a problem with Cucumber.
I don't know kow to say to Cucumber that "he" has to click on a pictur开发者_如何转开发e and then see some text...like I do with buttons or links.
When I click on a picture, I have to see the text "USER OK" in the screen.
How can I do that?
It sounds like you know how to click on links and buttons but not images. That probably has less to do with cucumber and more to do with the library you are using to control the browser (e.g. watir-webdriver or selenium-webdriver). If you let us know which one you are using we might be able to help more. If you don't know then just paste an example of your code that works for a link or button.
Based on the info you've provided so far I'm guessing you need to do something like browser.image(<some selector here>).click
Cucumber doesn't care about how it's done.
When I check the status
Then it says the user is OK
Hide the how in the step definition. Put the user task in the step description When I check the status, so if the way to check the status changes next from from clicking an image to double rt-click & spin the mouse wheel, it won't affect the tests. You just re-write the step definition innards. Same goes for the verification step. If the text changes from "USER OK" to a yellow happy face, you can still keep the step Then it says the user is OK and just change the innards of the step definition.
Now, do you have a question on how to write the step definition? In that case, you ought to provide a little info about library that is running your browser and some html for us to look at.
精彩评论