How to refresh the browser in a coded ui test - coded-ui-tests

My application is up and running in IE 9 but sometimes not everything loads properly on the page and it causes my coded ui test to fail. So I want to add code to my coded ui test to refresh (F5) the browser when this happens. How can I do this?

When you launch the web browser it returns an instance of the BrowserWindow object. That BrowserWindow object contains a Rrefresh method you can call:
BrowserWindow currentBrowser = BrowserWindow.Launch(new Uri("https://www.google.com/"));
currentBrowser.Refresh();
You can also call use the Locate method to get an instance of the BrowserWindow you are using if you need to do the refresh in a different place:
BrowserWindow currentBrowser = BrowserWindow.Locate("title of your browser window");
currentBrowser.Refresh();

Related

How to stop page refresh when changing url by history.replacestate in angularjs?

I'm updating my page URL from on a span click in my angularjs+jade+nodejs application.
http://192.xxx.0.xxx:7071/page-1/blog
to
http://192.xxx.0.xxx:7071/page-2/blog
I am using history.replaceState to change.
But as the function execute the page gets automatically refreshed.
I want to stop the reload using replaceState. Is there any other solution available?
If I write history.replacestate(null, null, '/page-2/blog') in console of browser it works perfectly fine.
You should take a look to "reloadOnSearch: false" .
If you add this in your angularJS module you can't disable the refresh
[reloadOnSearch=true] - {boolean=} - reload route with true, or false if you don't want to refresh .

wait for page load for non-angular Application using protractor

i am new to protractor and testing Non-Angular login Page and on clicking login button on login page a new page appears and i need to click on a planning link.But on clicking Login button application takes around 50 seconds.I want the protractor to wait untill the planning link appears.I used browser.wait(),browser.driver.implicitltyWait() but no success. I am able to click on planning link using browser.sleep() only.
Please help me to resolve the issue.
You need to wait for any WebElement in the page that is loaded after you perform login operation.
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(element(by.id("someId"))),60000)
it will wait for the element and throw exception after waiting for 1 minute
So what I understood from your question is that you have a non angular login page and click on login button takes you to another page(Is this angular or non angular?) which takes around 50 sec to load and contains a link(planning). Right?? And clicking on that link will take you to your angular home page.
And the issue which you are facing now is that the protractor is not waiting 50sec for the page containing the planning link to load.
Please try this and let me know the result..
this.clickLoginBtn = function () {
browser.driver.findElement(loginBtn).click();
return browser.wait(function () {
return browser.driver.isElementPresent(planningLink);
}, 50000);
};
I used browser.driver.findElement since we are on the non angular page.
I wrote a blog post about this, and have working examples on github, specifically when testing non-Angular apps. It makes use of Expected Conditions, and Page Objects.
If you're not using Page Objects yet, you'd do something like:
var EC = protractor.ExpectedConditions;
// Waits for the element with id 'loginBtn' to be clickable.
browser.wait(EC.elementToBeClickable($('#loginBtn')), 50000);

Controlling a web page, casperJS like : can that be done with chrome extension?

I am trying to develop a chrome extension to automtize some tasks on the web (fill form, go to next page, extract data...)
The idea is to develop a kind of http://casperjs.org/ as chrome extension.
I am injecting some JS to an active tab.
JS is run, and everything works fine: problems raise when I navigate to a new url.
When the page navigates to new url (document.location for instantce), the JS stops running since it is unloaded.
My idea would be to store the JS state and resume it once page has loaded:
ex content of source variable: I inject it in background to the web page.
for (i = 0;i < 5;i++) {
document.location = "http://www.example.com/page"+i;
waitUntilPageIsLoaded();
var source = $("body").html();
extractData(source);
}
chrome.tabs.executeScript(null, { code: source });
Of course this does not work since we change the location of the page.
Or more generally speaking, can casperJS can be developped using google chrome extension ?

Invoking Browser via application Icon Like Youtube Application Without Showing My Application

i want to invoke browser with a specific url like youtube application. I've try using Navigator Invoke but, its show my application. i dont want to show my application just show browser when user click the application icon, can anybody help me please ..
Put this into your main() in main.cpp
QDesktopServices::openUrl(QUrl("http://example.com",QUrl::TolerantMode));
But you MUST remove (comment) the following lines:
new ApplicationUI(&app);
return Application::exec();
Otherwise application will open anyway

chrome-extension:load data in background page

I‘m developing chrome extension.
user log in in options.html,and then application will load much data from web database.
but once user close options.html, the loading process will stop immediately.
I want to do the loading work in background page, but I don't how to program.
You can do you loading in background page.
function load_data() {
// do something
}
and then call it in your option page.
var app = chrome.extension.getBackgroundPage();
app.load_data();
then your loading process will keep running in the background.

Resources