Refresh a tab after information has been chnaged - kendo-ui

I have a tab strip using kendo for MVC. I'm trying to update the tab or reload a tab after the information has been changing.
For some reason it the reload does not work.
I have tried this using javascript:
var a = tabStrip= $("#summary-tabstrip").kendoTabStrip().data("kendoTabStrip");
tabstrip.reload("abcxyz");
Tab:
tabstrip.Add().Text("Screening")
.Enabled(true)
.Content(Html.Partial("~/Views/EyeTestReport/_Screening.cshtml", new Website.Models.EyeTestReport.ScreeningViewModel(Model.VisitID)).ToHtmlString()
).ContentHtmlAttributes(new { #id = "abcxyz"});
but it does nothing apparently.
Anything I can try? If you need anything else let me know and I will post.

Related

Laravel dusk coming back to original browser tab or close latest tab but keep original

I have situation where I need to click the link and visit new tab and see if there is that particular text or not and then come back to original tab and perform some work.
this is the code I am using to confirm I am in latest browser tab after clicking view button
$window = collect($this->driver->getWindowHandles())->last();
$this->driver->switchTo()->window($window);
Now I have to come to original tab, How can i do that ? Any help?
is there any way to close recent tab after some time. so that i can come to original tab.
Thanks
You're on the right track.
You can continue with something like this:
$this->browse(function (Browser $browser) {
$browser->visit('/')->click('#some-link');
// switch to the last tab
$window = collect($browser->driver->getWindowHandles())->last();
$browser->driver->switchTo()->window($window);
// make some assertion on that tab
$browser->assertRouteIs('some-route.alias');
// switch back to first tab
$window = collect($browser->driver->getWindowHandles())->first();
$browser->driver->switchTo()->window($window);
// TODO: make further assertions
});

Switch to another window in Cypress

I want to switch to to a new window on pressing a button, and the new window has dynamic URL, How do we handle this. Is there any workaround. I searched through many articles
Click the add button
cy.get('a[href*="javascript:xxxSearch();"]').click()
It opens a new window
I want to access(search/add the elements in new window and then switch back to previous main window
May be a good idea if you could share the full html of that page. As I understood from the question, may be grab the href and then get the attribute of href to a const and visit to that link as below. Just give a try and let me know if this is working for you.
it('Open a new window',function(){
cy.visit('some_url')
//test code continues....
cy.get('a[href="/some/link"]').then(($href)=>{
const hrefLink = $href.attr('href');
cy.visit(hrefLink);
// rest of you test to grab the search button
})
})

How to Scroll In an Android Tab Using UIAutomator

i am trying to Scroll Using UIAutomator. The Scenario is I am entering the Settings menu in the tab and clicking on Apps options which gives me a list of all the apps in the tab. NOw i want to scroll the list of apps and this is where i am facing issues.It scrolls the Settings options and not the App list. I am attaching a screen shot and my piece of code.
UiScrollable scroll = new UiScrollable(
new UiSelector().scrollable(true));
scroll.setAsVerticalList();
UiObject Apps = scroll.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()),
"Apps");
Apps.clickAndWaitForNewWindow();
UiObject Locker = scroll.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),"Content Locker");
Locker.clickAndWaitForNewWindow();
I am new to UiAutomator too and there is not very big amount of tutorials to learn it. I used Smrti example here, but some of the things already got deprecated, so I corrected it a bit to make everything work. Here's what I got
UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.pressHome();
UiObject allAppsButton = mDevice
.findObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.scrollIntoView(new UiSelector().text("Settings"));
mDevice.findObject(new UiSelector().text("Settings")).clickAndWaitForNewWindow();
mDevice.findObject(new UiSelector().text("Apps")).click();
I didn't include the search for certain app here, I'm sure you can manage it the same way as searching for the Settings app in my code snippet.
Say I want to click on App Facebook which is a little down the Apps list under Settings.
You can use this -
getUiDevice().pressHome();
allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.click();
appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
selector = new UiSelector().className(android.widget.TextView.class.getName());
appToLaunch = appViews.getChildByText(selector, "Settings");
if (appToLaunch != null)
appToLaunch.clickAndWaitForNewWindow();
new UiObject(new UiSelector().text("Apps")).click();
UiScrollable appViews1 = new UiScrollable(newUiSelector().scrollable(true));
appViews1.scrollForward();
appViews1.scrollTextIntoView("Facebook");
new UiObject(new UiSelector().text("Facebook")).click();
This should work.

How to call the same function that the ToolBar editbutton does

So I have created a context box upon right click that has Add/Edit/Delete Rows. I also have a bunch of code launched before the Dialog is shown. My problem is that when I use the context menu it doesn't go through some of the code. I have tried to call on the functions directly but it doesn't format correctly.
I am mainly concerned with the edit button, here is the code I am using to bring up the edit Dialog
function editRow() {
var grid = jQuery("#<%= Jqgrid1.ClientID %>");
var rowKey = grid.getGridParam("selrow");
if (rowKey) {
// I have tried calling functions here and it still doesn't work
grid.editGridRow(rowKey, grid.editDialogOptions);
}
else {
alert("No rows are selected");
}
}
So if I use this to display the editform it isn't formatted correctly nor does it go through the functions all correctly.
I am using the ASP Webforms version of Jqgrid so I call the function by doing this
<cc1:JQGrid1 ID="Jqgrid1
//other attributes
ClientSideEvents-BeforeEditDialogShown="ChangeMonitor"
//Rest of code />
So this works just fine, and I'm trying to get the Edit button on the context menu to display correctly.
My thought was to use Jquery to trigger a click on the actual Edit button once someone used the context menu. I couldn't find an ID that would work however.
Is there an easy way to connect my context menu Edit button, with the actual Edit button in the toolbar?
Well I found a solution to my problem.
The id field of the button was edit_ct100_cpMainContent_Jqgrid1_top so I just triggered a click with this code.
$("td[id^=edit][id$=top]").trigger("click")
For some reason when I used the _ct100_cpMainContent_Jqgrid1 it wasn't working, but now it does. Hope this helps someone.

How to "bookmark" page or content fetched using AJAX?

How to "bookmark" page or content fetched using AJAX?
It looks like it can be easy if we just add the details to the "anchor", and then, use the routing or even in PHP code or Ruby on Rails's route.rb, to catch that part, and then show the content or page accordingly? (show the whole page or partial content)
Then it can be very simple? It looks like that's how facebook does it. What are other good ways to do it?
Update: There is now the HTML5 History API (pushState, popState) which deprecates the HTML4 hashchange functionality. History.js provides cross-browser compatibility and an optional hashchange fallback for HTML4 browsers.
To store the history of a page, the most popular and full featured/supported way is using hashchanges. This means that say you go from yoursite/page.html#page1 to yoursite/page.html#page2 you can track that change, and because we are using hashes it can be picked up by bookmarks and back and forward buttons.
You can find a great way to bind to hash changes using the jQuery History project
http://www.balupton.com/projects/jquery-history
There is also a full featured AJAX extension for it, allowing you to easily integrate Ajax requests to your states/hashes to transform your website into a full featured Web 2.0 Application:
http://www.balupton.com/projects/jquery-ajaxy
They both provide great documentation on their demo pages to explain what is happening and what is going on.
Here is an example of using jQuery History (as taken from the demo site):
// Bind a handler for ALL hash/state changes
$.History.bind(function(state){
// Update the current element to indicate which state we are now on
$current.text('Our current state is: ['+state+']');
// Update the page"s title with our current state on the end
document.title = document_title + ' | ' + state;
});
// Bind a handler for state: apricots
$.History.bind('/apricots',function(state){
// Update Menu
updateMenu(state);
// Show apricots tab, hide the other tabs
$tabs.hide();
$apricots.stop(true,true).fadeIn(200);
});
And an example of jQuery Ajaxy (as taken from the demo site):
'page': {
selector: '.ajaxy-page',
matches: /^\/pages\/?/,
request: function(){
// Log what is happening
window.console.debug('$.Ajaxy.configure.Controllers.page.request', [this,arguments]);
// Adjust Menu
$menu.children('.active').removeClass('active');
// Hide Content
$content.stop(true,true).fadeOut(400);
// Return true
return true;
},
response: function(){
// Prepare
var Ajaxy = $.Ajaxy; var data = this.State.Response.data; var state = this.state;
// Log what is happening
window.console.debug('$.Ajaxy.configure.Controllers.page.response', [this,arguments], data, state);
// Adjust Menu
$menu.children(':has(a[href*="'+state+'"])').addClass('active').siblings('.active').removeClass('active');
// Show Content
var Action = this;
$content.html(data.content).fadeIn(400,function(){
Action.documentReady($content);
});
// Return true
return true;
And if you ever want to get the querystring params (so yoursite/page.html#page1?a.b=1&a.c=2) you can just use:
$.History.bind(function(state){
var params = state.queryStringToJSON(); // would give you back {a:{b:1,c:2}}
}
So check out those demo links to see them in action, and for all installation and usage details.
If you use jquery, you can do that in a simple manner. just use ajaxify plugin. it can manage bookmarking of ajax pages and many other things.
Check this, something may help you:
How to change URL from javascript: http://doet.habrahabr.ru/blog/15736/
How to pack the app state into url: http://habrahabr.ru/blogs/javascript/92505/
An approach description: http://habrahabr.ru/blogs/webstandards/92300/
Note: all articles are in Russian, so either Google Translate them, or just review the code and guess the details.
Take a look to the Single Page Interface Manifesto
I tried many packages. The jQuery History plugin seems to be most complete:
http://github.com/tkyk/jquery-history-plugin

Resources