watir: content of frame.body is not updated (is there any refresh method) - phantomjs

Hi I am using watir for cucumber test of PHP project.
Unfortunately page is always make from two frames.
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7">
<title>Rothschild - Olomouc</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/skripty.js"></script>
</head>
<frameset cols="183,*" frameborder="NO" border="0" framespacing="0" rows="*">
<frame name="leftFrame" scrolling="AUTO" noresize src="">
<frame name="mainFrame" src="getuser.php">
</frameset>
<noframes>
<body id=body bgcolor="#FFFFFF" text="#000000">
</body>
</noframes>
</html>
leftFrame is menu,
mainFrame is main page content.
I use
if headless
#browser = Watir::Browser.new :phantomjs #headless
else
require 'watir-webdriver'
#browser = Watir::Browser.new :ie #non headless,IExplorer
end
main_content= #browser.frame(:name, "mainFrame").body
to get content of main part of page.
It works almost every time.
But now I get to situation when doubleclicking on TR
<tr class="subTable dealer_1" onDblClick="window.location.href='detail_dealer.php?id=207'">
<td><a name="a207"></a></td>
<td> Lama Mirek</td>
<td> Ústí n. Orlicí</td>
<td></td>
</tr>
get me to page detail_dealer.php?id=207 (in mainFrame of course)
but
#browser.frame(:name, "mainFrame").body
gives me previous table (with doubleclicking rows).
When I try to debug it with PRY
pry:> #browser.frame(:name, "mainFrame").body => content of desired detail page
It looks like watir needs a time to "reload" content of body. Is there some method to do "refresh" or "wait until new content is loaded"?
This happens with both drivers watir-webdriver and phantomjs.

Watir has a number of methods for waiting.
You will need find an element that only exists after clicking on the tr element. Then call one of the wait methods. For example:
browser.element.wait_until_present
Alternatively, you can also wait for an element to be removed after the tr is clicked:
browser.element.wait_while_present

Related

The static resource cannot be accessed in grails3. How can I fix it?

I used grails3.1.2 to create my app. It's normal but now it isn't. My app contains a sub-app which is just html, js, css and so on. I put this sub-app under src/main/webapps folder. From my browser, I found all js and css used by html is not available.
I tried to adjust location of sub-app to src/main/resource/public , but it doesn't work for me.
My app has a gsp contains html as follow:
<%# page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title></title>
</head>
<body>
%{--<iframe height="100%" width="100%" src="<asset:assetPath src='events-list.html?t=${java.lang.System.currentTimeMillis()}' />" frameborder="0" />--}%
<iframe height="100%" width="100%" src="${resource(dir:'admin',file:'events-list.html')}" frameborder="0" />
</body>
</html>
The html used some js and css:
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
But those js and css is not accessed by browser(browser cannot find them)
I don't understand why it got worse. Hope you could submit some advises

SoundCloud: callback.html popup doesn't close

I've registered my SoundCloud app.
I'm trying to implement the SoundCloud JS example code with the "callback.html" API
https://developers.soundcloud.com/docs/api/sdks#authentication http://connect.soundcloud.com/examples/recording.html
When I upload a recording, I get the authorization-login popup.
After I login, the popup says "This popup should auto close..."
But the popup doesn't close.
And the recording isn't uploaded.
I'm positive SC.initialize has my correct "clientID" and is referencing "callback.html" correctly from my directory.
Am I missing something? maybe "client secret"?
SC.initialize({
client_id: "xxxxxxxxxxxxxxxxxxxxxx",
redirect_uri: "http://www.example.com/callback.html"
});
One time (fluke) instead of the normal pop msg "This should close", the message said "502 Bad Gateway". But I havent been able to reproduce this msg.
SoundCloud's sample code is broken.
This is from SoundCloud's callback.html
<body onload="window.opener.setTimeout(window.opener.SC.connectCallback, 1)">
This is how I got it to work:
<body onload="window.setTimeout(window.opener.SC.connectCallback, 1)">
SoundCloud's connectCallback uses this.location to collect the OAuth access token. If you set the timeout on window.opener, inside connectCallback this will refer to your app's window and the location will be your main page. Whereas setting it on window will bind this to the callback popup window, and this.location will contain the access token in the query arguments.
I also faced the same issue, and found the solution, if you change your callback.html to below two options, it will work -
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Connect with SoundCloud</title>
</head>
<body onload="window.opener.setTimeout(window.opener.SC.connectCallback, 1)">
<b style="text-align: center;">This popup should automatically close in a few seconds</b>
<script type="text/javascript">
window.opener.SC.connectCallback.call(this);
</script>
</body>
</html>
Or
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Connect with SoundCloud</title>
</head>
<body onload="setTimeout(window.opener.SC.connectCallback)">
<b style="text-align: center;">This popup should automatically close in a few seconds</b>
</body>
</html>

UIWebView and Bootstrap css tables

I am creating an application that will show to the user a formatted message in an UIWebView loading local HTML content.
I am using GRMustache to render the html to be displayed and bootstrap as css.
Everything works fine, the css is loaded, but when i want to display tables, the css is not recognized.
I don't know if UIWebView is not capable to recognize the css of the tables, but in the apple documentation just read that have the same capabilities than safari.
Here i put my template.
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
{{style}}
</style>
</head>
<body>
<h1> Message </h1>
<button class="btn btn-success"> Button </button>
<table class="table table-striped">
<tbody>
{{# detalle}}
<tr >
<td> {{capitalized(key) }} </td>
<td> {{ capitalized(object)}} </td>
</tr>
{{/ detalle}}
</tbody>
</table>
</body>
Here is an image of my UIWebView:
https://www.dropbox.com/s/or5vrqxxqbjqjoh/bootstrap%20app.png
The button css is rendered fine, but the table is not striped.
I checked my css, thinking than that was the problem, but it was just fine.
In this moment I can't find an answer for this problem.

IE 10 Beta - window.showModalDialog ignores dialogHeight and dialogWidth when opening window which has framset in it

Note: Issue occurs only with IE 10 Beta release
Scenario:
a.html has showModalDialog to open b.html:
window.showModalDialog(b.html, self, 'dialogHeight=800px;dialogWidth=900px');
b.html has frameset in it :
<%# Page Language="vb" AutoEventWireup="false" Codebehind="somefile.aspx.vb">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<HTML>
<HEAD>
Some Title
</TITLE>
</HEAD>
<frameset rows="40px,*" border="0" frameSpacing="0" frameBorder="0">
<frame src="myfile.aspx" noresize height="100%" width="100%" scrolling="no">
</frameset>
</HTML>
Issue:
When I try to open b.html using window.showModalDialog from a.html, the popup appears in a small window though I gave dialogHeight and dialogWidth. This happens only with IE10. I am using beta version. Please help.
I have been able to work around the issue by specifying a document compatibility mode in the framesest page:
<meta http-equiv="x-ua-compatible" content="IE=7" >

dojo debugging EnhancedGrid with ItemFileReadStore

I'm following the example in "Mastering Dojo", Chapter 3, with dijox.grid.Grid. I've modified it slightly to use dojox.grid.EnhancedGrid. I've written a web service that returns some json in the format required by dojo. I've tested the web service independently and it returns the correct json. But when I put EnhancedGrid together with ItemFileReadStore it does not produce any errors in the browser error console but also does not display any data in the grid.
What steps can I take from here to debug this? Is there some verbose debugging flag I can give to dojo so that it (hopefully) clues me into what is going wrong?
EDIT:
Here's what I'm doing:
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js" djConfig="parseOnLoad:true, isDebug:true"></script>
<link rel="stylesheet" href="/css/main.css"/>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/resources/dojo.css"/>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dijit/themes/claro/claro.css"/>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojox/grid/enhanced/resources/claro/EnhancedGrid.css"/>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/enhanced/resources/EnhancedGrid_rtl.css"/>
<script type="text/javascript">
dojo.require("dojo.parser");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.grid.EnhancedGrid");
</script>
</head>
</body class="claro">
<style>
#msgs {
width=550px;
height=200px;
}
</style>
<div dojoType="dojo.data.ItemFileReadStore" jsId="xstore" url="/path/to/my/resource/data.json"></div>
<table id="msgs" dojoType="dojox.grid.EnhancedGrid" store="xstore">
<thead>
<tr>
<th field="id" width="50">Id</th>
<th field="ts" width="100">Date</th>
<th field="msg" width="400">Message</th>
</tr>
</thead>
</table>
</body>
</html>
The javascript returned is like this:
{
"identifier":"id",
"items":[
{
"id":"3425",
"custId":"2342525225",
"ts":"2011-07-23T07:00:00Z",
"msg":"test message"
}
]
}
I guess one open question: the json has one extra column that's not displayed in the table ("custId"). I'm hoping that this does not cause problems?!
EDIT2:
Also if I go into firebug's DOM console, I can see that xstore variable correctly holds the data from the JSON.
The two things that work are:
setting an inline style on the table to set the width/height, OR
set the EnhancedGrid property autoHeight which is what I ended up doing.