Spock: if-else check in spock - Check element visibbility - if-statement

I need to click login button if logout button is not displayed and logout button if login button is not displayed.
How I can check this in when,then blocks in Spock?
I mean how if-else is supported in Spock?
In the Page, I have the content like below:
logout(required: false) { $("a",text:"ログアウト") }
than I have to check if ログアウト which mean logout is present or not.
This question does not address my issue becasue it is checking a Boolean value which is being checked in the last part of the def. If I have more code to execute after this check, and if I cannot take actions if the Boolean is false in an else like block, than I cannot go ahead.

The main concept of tests is check each functionality separately.
I can't understand from the question what is the code check.
But the recipe should be like that:
First test:
setup: Make all the conditions so the logout button is not displayed.
when: press the login button.
then: Check the behavior.
Second test:
setup: Make all the conditions so the login button is not displayed.
when: press the logout button.
then: Check the behavior.
It is better not checking 'if else' statement in the same test.
The separation enables checking each part of the 'if else' by itself.

Related

Show and Hide submit button depending on selected value

I'd like to get some help on an issue I'm having. I have a button that submits a page , I would like to be able to hide the button by default and show it if the value of a filed changed from "under waiting" to "accepted" or "refused" only. i tried to do that using dynamic action show and hide but i can not .What is the best way to make this happen.
Hard to say what is wrong with your code if the only hint you give is "i can not" :).
This works for me:
Create a page with a region that has item P85_SELECTLIST, a hidden item P85_OLD_STATUS and a button SUBMIT.
create a computation on P85_OLD_STATUS (process point: after P85_SELECTLIST has been initialized) of type item with value P85_SELECTLIST. This sets P85_OLD_STATUS to the value that P85_SELECTLIST has at page load.
define P85_SELECTLIST as "Static Values" with values:
Create a dynamic action on page load with action "Hide" button SUBMIT.
Create a dynamic action on change of P85_SELECTLIST (note that the values are the return values, not the display values). Add a server side condition to this dynamic action (this will ensure the dynamic action never fires if the initial value is not UNDERWAITING).
Add a true action of "Show" button SUBMIT to the dynamic action.
Add a false action of "Hide" button SUBMIT to the dynamic action.
That's it. If initial value is "Other", changing the value has no effect. If initial value is "UNDERWAITING" and it is changed to ACCEPTED or REFUSED button is shown.

Bot Framewok Composer - "Replace this dialog" causes an error 400

I'm building my first chatbot with bot Framework Composer and I don't succeed in building a very simple scenario.
I looked deeply in the Bot Framework Composer Documentation but found nothing helpful.
Child Scenario I want to achieve:
Bot asks/prompts 'Says something plz'
User answers/types a string, something like 'anAnswer'
Bots says "You said 'anAnswer', is it correct ?"
User types "yes" or "no"
if user typed "yes" : End of dialog
if user typed "no" : repeat this dialog
See the Bot Composer Canvas here
The problems I face :
1. "Repeat this dialog" does not work as I expected.
The emulator keeps telling me :"Recursive loop detected, AdaptiveDialog cannot be repeated twice in one turn"
I tried to turn the "Allow Loop" on "True" but it seems to result on a infinite loop (though I don't know how I can check that...)
See the "Repeat the dialog" options here
Do I have to add something in the "Options" of the "Repeat the dialog" action ?
Like where the loop have to start ? If so, how to do that ?
2. How to use "Replace this dialog" with a scenario already used ?
As I didn't succeed with the "Repeat the dialog" action, I then tried to cut in half the whole dialogue by dividing it in two dialogues. Each dialogue have one goal :
the first scenario is for asking information to the user
the second scenario is for asking confirmation to the user
See the "Ask for infos" dialog here
See the "Confirmation" dialog here
The initial goal was to "redirect" the user toward the "Ask for infos" dialog when he whant to edit what he typed previously.
But here, it results on a error : POST400directline/conversations/<conversationId>/activities
Here again there are some "options" possibles for the "Replace the dialog" action, but I didn't found anything in the documentation on this subject.
Thanks a lot for helping a newbie, I'll gladly try the solutions you bring me and make the feedback.
Have a great day,
PS : Do you know a good tutorial on Bot Framework Composer (other than the Microsoft ones ?)
Before using the Repeat the dialog action you have to clear the variable storing the user answer. The reason its looping is the bot already have an answer in memory so it wont prompt the user again.
use the 'Set a property' action and set the variable value to null before repeating the dialog

differentiate betwwen forward and backward navigation on a page Ionic2

How can I differentiate that whether a page comes into view from forward or backward navigation. I want to run some code only if it is forward navigation.
CASE 1 :- Say you are navigating from 1 page to another - Forward. I.e. using navCtrl.push(Page,params).
Here, you can put your code in constructor(){}. Code in your constructor always gets executed when you push/navigate to a page - Forward. (Rather than push, you can also reset the stack to a rootpage. This is valid then also.)
CASE 2 :- Say you are navigating back from a page - Backward. I.e. manually going back by user in the app or using navCtrl.pop().
Here, I think, there is NOT any in-built way to recognise if you have navigated on a back page. Here you need to build your own logic.
For e.g, PageA -> PageB is your navigation. I have used localStorage variable to set to some value, (e.g localStorage.setItem('isPushed',true)) when navigating from PageA -> PageB.
Now, in PageA I have written this code using ionViewWillEnter():
ionViewWillEnter(){
if(JSON.parse(localStorage.getItem('isPushed')){
localStorage.setItem('isPushed',false);
// Your Code to be executed when entering to back page.
}
}
ionViewWillEnter() always gets executed when the particular page is navigated. So, my idea here is just to detect if it is navigated from a next page to a back page. Hope this helps. :)
NOTE : I have not handled all the conditions related to this. That you have to work it out. This is just an idea of logic to use.

No result with SendKeys to IE8 using Selenium on BrowserStack

I'm using Selenium to perform testing on BrowserStack, and have hit a problem while testing IE8.
I've found that when I target elements and then call Click, the full effect of the action is not being undertaken*.
Through trial-and-error I found that if I call Click twice then the expected action is undertaken.
However, one of the testing steps involves writing a number to a text field, and for this I have the following:
driver.FindElement(By.CssSelector("...")).Click();
driver.FindElement(By.CssSelector("...")).Clear();
driver.FindElement(By.CssSelector("...")).SendKeys(Keys.NumberPad1);
driver.FindElement(By.CssSelector("...")).Click();
But "1" never appears in the field. I can tell it never appears because I'm capturing screenshots after each step; I can see that the field gets highlighted (as the active element) and I can see the cursor inside the field, but no result from the method call.
Furthermore, I've even tried giving the field an ID and addressing it with
driver.FindElement(By.Id("txtCountManual")).SendKeys(Keys.NumberPad1);
But with the same (lack of) results.
Does anyone have any suggestions as to how I may send a textual value to a field in IE8 using Selenium and BrowserStack?
* The "expected action" involves using Knockout.js to display a selected value in another element. So for example, I found that if I programmatically click a radio button and then take a screenshot, I can see that the radio button has been clicked but the action performed by Knockout.js has not taken place; if I click the element a second time then the Knockout.js action is performed. This double-clicking is not required when I manually test using IE8 via BrowserStack.

Ember.js adding and removing views from the DOM?

I am looking into ember.js, after working with SproutCore 1 previously. I am looking for some examples on how to add and remove views from the DOM as the user navigates the application.
For instance, I have an application that contains a set of cases and each case has a workflow. There are also administration pages, etc.
When the user starts up the app, a dashboard-like user interface is shown. From here the user is able to search or click on a case in order to bring up that case. At this point I want to do the following:
I want to remove the GUI for the Dashboard, and i want to show the GUI for the case - which is a complex GUI in itself with its own set of navigation rules etc.
Also, within the case I want to add and remove portions of the GUI as the user navigates and manipulates the case.
When the user clicks on the "Dashboard" link, I want the current GUI to be removed, and the dashboard to be added again.
As this will be a somewhat large application I am not sure if toggling the isVisible parameter is sufficient, or if other measures needs to be taken in order to not overload the user's browser.
Is there a guide, or an example that shows how to do this ?
WARNING: OUTDATED ANSWER
A view inherits from Ember.View which means it gets some key methods. append(), which appends to body, appendTo(arg) which takes an argument and remove().
The argument is a jQuery style selector of where to insert the element in the DOM.
// my view
App.PartsView = Ember.View.extend({
...
});
// create/insert my view
App.partsView = App.PartsView.create();
App.partsView.appendTo('#partcontainer');
In my code I have a <div id="partcontainer"></div>.
// remove from DOM
App.partsView.remove();
The documentation has a good part on Building a View Hierarchy and later a section on Ember.ContainerView depending on whether you want to do it all programatically or not.