Best way to run an action until expected condition is met in Nightwatch.js? - automation

I am automating a portion of a website that kicks off a job when you click a button. The status of the job is reported on the page in another field, but it isn't automatically pushed. The end user needs to click a Refresh button inside the page to see the latest status.
Something like this
browser.expect.element('#status').text.to.equal('Done').before(10000);
would work if the data was pushed without using interaction, but since I have to manually click another button to get the latest status that wouldn't work.
Is there a built in method to do something every [interval here] until [condition true] or [timeout reached] in Nightwatch? I don't want to use a hard pause since the job could take more or less time depending how the server is feeling.

By another field do you mean an iFrame, svg or perhaps another tab/window?
You don't need manually, there is an option to switch to a different window with the following:
Window Handles + SwitchTo:
command(windowNum){
const result = browser.windowHandles();
let handle = result.value[windowNum];
browser.switchWindow(handle);
}
Refresh a page
browser.refresh();
I don't believe there is a built in method in Nightwatch but I'm sure you can use a for loop and an if statement

Related

Splunk submit button (submitButton) does not refresh dashboard if no inputs are changed

I have a dashboard with a submit button (submitButton). The search isn't run until the button is pressed which is exactly what I want (the search takes a long time). I don't want the search starting as the user changes the other dropdowns (time), environment (Prod vs. QA), etc.
HOWEVER, sometimes it would be nice to hit the submit button and perform the search again without changing any of the other fields (time, environment, etc.). In this case the submit button does nothing! I can tell the underlying data has changed via searches, but the dashboard is not updated. Simply changing any of the fields, doing a search, and then changing them back and searching again solves the problem, but surely the submit button should just work w/o this workaround?
Thanks
If "nothing" has changed, then Submit is supposed to "do nothing".
If you want to refresh the page with all the parameters as set, you should be able to click the URL bar and press return (so long as there are no hidden tokens, they'll all get set in the query portion of the URL).
Each panel in the dashboard should (automatically) have a refresh button you can click to refresh the display without changing inputs.
Unfortunately, this is intended behavior.
I also wish that the submit button would rerun dashboard searches. I opened a post on Splunk ideas about this issue:
https://ideas.splunk.com/ideas/EID-I-739
If you have a splunk.com account, you can vote for this idea.
I've browsed through Internet and found some solution that with some modifications worked for me fine
<form>
..
<html>
<style>
div.fieldset.dashboard-form-globalfieldset div.dashboard-element.html.dashboard-element-html {
display: inline-block;
}
</style>
Refresh
</html>
...
<form/>
so basiclu im refreshing page with all of its attributes and passing attributes values form current ones chosen using tokens. splunk code didn't like & so replaced it with & and it worked fine. <> - can be found in your splunk page address.

Allow natural back button behaviour with use case of dynamically-added query parameters

I have the case that I push some parameters to the nuxt router (https://router.vuejs.org/guide/essentials/navigation.html) whenever somebody visits a page without any parameters.
Example:
somebody visits: /program it will end up in /program/first-event?year=2018&month=6
(First the view filters the program for current events (therefore the parameters for this year and this month) and then from the filtered events it will set the first event as active post (also by pushing it to the router).
This is all wanted and good. BUT now I detected the following problem:
Somebody is visiting /aboutus and then navigates to /program, the router will automatically change to /program/url-of-event-post?year=2018&month=6.
Assuming the user wants to go back to /aboutus he clicks on the browser back button. This will bring him back to: /program which automatically adds the post and the parameters again (effectively moving one step forward again).
Means the user is caught in clicking endlessly on the back button.
My approach would be to try to register if a user clicks on the back button and if so, I would not add the parameters. But I don't know how to do this.
I thought the router would provide some 'from' property, but so far I did not find anything.
I would be very happy to hear some thoughts on this. Thank you heaps in advance.
You need use router.replace.
https://router.vuejs.org/guide/essentials/navigation.html#router-replace-location-oncomplete-onabort

How to test ajax application using webdriver?

Is there some specific way to test ajax based web application using webdriver?
Yes you should be careful when you write tests for pages that use JavaScript/Ajax heavily.
Main point in such case is to use wait condition each time you do something and result is not available instantly or via page change. When you need to add a wait condition examine behavior of the page and try to find some event that is a sign for you that operation is completed (attribute change, new element appears or disappears and so on).

titanium - get the current window

I'd like to be able to show an error message (or maybe even a success message!) to the user. However, this would be for an asynchronous event - so it is presumably possible for the user to have jumped to another page in-between the sending for the event and the response.
Given that that is the case, and given that i use a tabgroup as the "base" in the initial app.xml, how am i meant to access the current window? Ti.UI.getCurrentWindow() doesn't do anything on my system - no error, no nothing.
I'm using the Titanium 3 api.
Since your using a tab group you can use Titanium.UI.currentTab. Then you can get the window of the tab like this:
var theWindow = Titanium.UI.currentTab.window;
Specific doc reference (just in case).
Also, you can always use a Titanium.UI.AlertDialog, that will show up no matter what window your on, if it meets your requirements.
Yes you can use
Ti.UI.currentTab.window().
and since this is function so use "()", otherwise it will not give correct output
to get current window use Ti.UI.getCurrentWindow and not Ti.UI.getCurrentWindow()
Ti.UI.currentWindow only works if there is a window already open. The error you have is coming from the fact that when you create the MasterView, you have not yet opened up the window.
Look inside ApplicationWindow.js, you will see that you create the masterview before even opening the window.
If you want to set navbar items, either add them in the ApplicationWindow, app.js, or pass the window to the MasterView.
currentTab only works if your app uses tabs.
currentWindow and getCurrentWindow() only work if the window was opened using the url property of the Ti.UI.createWindow method.
If you're in any other situation, the current window is just not available, it seems.

One time actions in Chrome API

I am making an extension for Chrome as a browser action. I need to know if there is any way to have some functions executed while installing the app. All of the pages that I have seen like "background" and "popup" execute everytime. I need to configure the extension and then use these parameters further in my extension.
Is there a way to do so or I will have to put a check everytime the browser starts.
Best practice is to use a background page and localStorage. Each time the background page starts check if localStorage.getItem('installed') === 'true' to see if it is a new istall or not.
Background pages start when Chrome starts vs browser action popups that start every time a user clicks the button.