My actionscript 2 code in my frame 1 (called main) is as follows:
import flash.external.ExternalInterface;
ExternalInterface.addCallback('getStr', getStr);
function getStr(): String {
return "Hello World!";
}
And here is how my javascript code is trying to call it:
<!DOCTYPE html>
<html>
<head>
<script>
function getStr() {
var swf = document.getElementById("GETSTRSWF");
var str = swf.gtStr();
alert(str);
return false;
}
</script>
</head>
<body>
Get Str
<object id="GETSTRSWF" type="application/x-shockwave-flash" data="getStr.swf" width="0" height="0">
<param name="movie" value="getStr.swf" />
<param name="allowscriptaccess" value="always" />
</object>
</body>
</html>
But I get this error, and it fails:
TypeError: swf.gtStr is not a function
var str = swf.gtStr();
Related
I am trying to automate a page which has various element types. I am able to login and navigate till that page using Protractor,TypeScript,jasmine2 combination
When i try to enter a text in a field, it throws
Message: Failed: element not interactable.
Does it mean that the entire ng-controller or ng-scope is disabled for element interaction for automation?
Please let me know a solution if there is a way to enable the elements in the page on pageLoad ?
import { browser, by, element } from 'protractor';
import { Locator } from 'protractor/built/locators';
import { PageObjects } from '../TestPageObjects/OR';
import { TestData } from '../TestData/TD';
var po= new PageObjects();
var data= new TestData();
describe('Login', function() {
it('Login to Server', function() {
browser.get('http://server01/test/testapp.html');
element(<Locator>by.xpath(po.login_username)).sendKeys(data.username);
element(<Locator>by.xpath(po.login_password)).sendKeys(data.password);
element(<Locator>by.xpath(po.login_loginBtn)).click();
element(<Locator>by.xpath(po.MainMenu_setup)).click();
element(<Locator>by.xpath(po.SETUP_company)).click();
element(<Locator>by.xpath(po.COMPANY_companyDetails)).click();
browser.switchTo().frame(element(by.id('ifmPortalInfrastturcture')).getWebElement());
browser.sleep(10000);
browser.element(<Locator>by.xpath(po.CompanyName)).clear();
browser.element(<Locator>by.xpath(po.CompanyName)).sendKeys('ANN');
});
});
I expected the behavior to be like entering the text but the terminal showed element not interact-able.
PageObject (PO) selector is below:
export class PageObjects
{
public login_username: string ='//*[#id="username"]';
public login_password: string ='//*[#id="password"]';
public login_loginBtn: string ='//*[#id="btnSubmit"]';
public MainMenu_setup: string ='//a[span[text()="Setup"]]';
public SETUP_company: string ='//a[span[text()="Company"]]';
public COMPANY_companyDetails: string ='//a[span[text()="Company Details"]]'
public CompanyName: string = '//label[contains(.,"Company Name")]/following::input[1]';
//a[span[text()="Receipts"]]
//a[span[text()="Control Text"]]
}
HTML Page is below:
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="portalInfrastructure" dir="ltr">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>iProof Axon</title>
<link rel="icon" href="favicon.ico" type="image/ico" />
<style>
#font-face {
font-family: 'FontAwesome';
src: url('iProofCDN/Templates/Default/Styles/LTR/assets/css/Common/icons/fontawesome/fonts/fontawesome-webfont.eot?v=4.7.0');
src: url('iProofCDN/Templates/Default/Styles/LTR/assets/css/Common/icons/fontawesome/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),
url('iProofCDN/Templates/Default/Styles/LTR/assets/css/Common/icons/fontawesome/fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),
url('iProofCDN/Templates/Default/Styles/LTR/assets/css/Common/icons/fontawesome/fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),
url('iProofCDN/Templates/Default/Styles/LTR/assets/css/Common/icons/fontawesome/fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),
url('iProofCDN/Templates/Default/Styles/LTR/assets/css/Common/icons/fontawesome/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body ng-controller="PortalInfrastructureController as menuList" class="pace-done " ng-init='setPageUrlByPageType("Authenticate", "#pageManager")' id="bdyPageManager">
<div id="pageManager"></div>
<div id="MultiWindowRight" class="noItem " style="display:none">
<img data-imgsrc="/Templates/Default/Styles/LTR/assets/images/RightArrow.png" />
<div class="MultiWindow"></div>
</div>
<script type="text/javascript" src="iProofCDN/Templates/Default/Scripts/JsBundle/Common/ProofConfig.js"></script>
</body>
</html>
<script type="text/javascript">
window.top.ScriptLoader('PageManager', window.document, function () {
//default
});
</script>
with some research one of my colleague found a solution.
The container elements were hidden for access and we unlocked using the following script:
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById('Parks').style.display='block';");
NOTE: a Div named "Parks" was a child inside the xmlns which is again a child of an iFrame.
I want to give property "host" the value of the requested parameter "ip", submitted using method Get in form.html
This is my index.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ip</title>
</head>
<body>
<jsp:directive.include file="form.html"/>
<% if (request.getParameter("ip") == null ||
request.getParameter("ip") == ""){%>
Not connected!
<% } else {%>
<jsp:useBean id="connect" class="test.Ip" />
<jsp:setProperty name="connect" property="host" value="Connect" />
<jsp:getProperty name="connect" property="host" />
<% }%>
</body>
</html>
This is the included file form.html
<form action="index.jsp" method="GET">
Connect to IP: <input type="text" name="ip"/>
<input type="submit" value="Connect">
</form>
This is the Java file Ip.java
package test;
public class Ip{
private String host;
public String getHost(){
return("Got value " +host);
}
public void setHost(String host){
this.host = host;
}
}
It returns the string "Got value Connect" instead of the value I type in the form.
First of all, to compare strings, you need to use method equals, as you will otherwise compare two object which will not be the same
Change:
request.getParameter("ip") == ""){%
To:
request.getParameter("ip").equals("")){%
then you want to set the property host to the parameter ip
Change:
<jsp:setProperty name="connect" property="host" value="Connect" />
To (As the name attribute of the textfield is ip and not Connect, that's the button):
<jsp:setProperty name="connect" property="host" param="ip" />
My struts version is 2.3.15.3
In my current struts2 project, all post requests do not redirect to get requests
So I will get resubmit alert when I click the back button if I use https and chrome
How to use minimum effort to change them to keep using post request, but use get redirect to show the JSP? Can I just modify the struts.xml?
Or, is it possible to prevent the alert without PRG?
this is my current code
struts.xml:
<action name="Get" class="test.PostAction">
<result name="gotoform">/WEB-INF/jsp/PostForm.jsp</result>
<result name="success">/WEB-INF/jsp/showGet.jsp</result>
</action>
PostAction.java:
public class PostAction extends ActionSupport{
#Override
public String execute() throws Exception {
Map para = ActionContext.getContext().getParameters();
if(para.get("post")==null)
{
return "gotoform";
}
else
{
return "success";
}
}
}
PostForm.jsp:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="Get.action" method="POST">
<input type="text" name="post" value="yes">
<input type="submit">
</form>
</body>
</html>
showGet.jsp:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Display here</h1>
</body>
</html>
New showGet.jsp:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Display here, Post value=</h1> <%= request.getParameter("post") %>
</body>
</html>
new PostAction.java:
package test;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.Map;
public class PostAction extends ActionSupport{
private String post;
#Override
public String execute() throws Exception {
Map para = ActionContext.getContext().getParameters();
System.out.print("post = "+post);
if(para.get("post")==null)
{
return "gotoform";
}
else
{
return "success";
}
}
public String getPost() {
return post;
}
public void setPost(String post) {
this.post = post;
}
}
new 2 showGet.jsp:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Display here</h1>,
<s:property value="post"/>,
${post},
<%= post %>,
<%= getPost() %>
</body>
</html>
Additional action required to expose redirectAction result.
<action name="showGet">
<result>/WEB-INF/jsp/showGet.jsp</result>
</action>
<action name="Get" class="test.PostAction">
<result name="gotoform">/WEB-INF/jsp/PostForm.jsp</result>
<result name="success" type="redirectAction">showGet</result>
</action>
I'm using Jaris flv player to play flv videos.
It can open the page and display normally when I directly open the page(http://mysite.com:8080/TSE/flv/player.jsp).
But if I redirect and open the page from struts action's return, it can not work(http://mysite.com:8080/TSE/multidocdetailDoc.action?selectId=C94DC060947048B188BB2FAF1804B0F3).
The page displays the alternative content (the case of no adobe flash).
What should I do?
the action did nothing except redirect:
public String multidocdetail(){
try {
String selectId = getRequest().getParameter("selectId");
System.out.println(selectId);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return "multidocDetail";
}
struts:
<action name="*Doc" class="casco.com.tse.action.learn.DocAction" method="{1}">
<result name="docDetail">/jsp/learn/docDetail.jsp</result>
<result name="multidocDetail">/flv/player.jsp</result>
</action>
the jsp is just like the example of jaris website:
<%# page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Jaris FLV Player</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvarsVideo = {
source: "http://localhost:8080/TSE/flv/mv/CTCS-3.flv",
type: "video",
streamtype: "file",
server: "",//Used for rtmp streams
duration: "52",
poster: "http://localhost:8080/TSE/flv/poster.png",
autostart: "false",
logo: "http://localhost:8080/TSE/flv/logo.jpg",
logoposition: "top left",
logoalpha: "30",
logowidth: "130",
logolink: "http://jaris.sourceforge.net",
hardwarescaling: "false",
darkcolor: "000000",
brightcolor: "4c4c4c",
controlcolor: "FFFFFF",
hovercolor: "67A8C1"
};
var params = {
menu: "false",
scale: "noScale",
allowFullscreen: "true",
allowScriptAccess: "always",
bgcolor: "#000000",
quality: "high",
wmode: "opaque"
};
var attributes = {
id:"JarisFLVPlayer"
};
//swfobject.embedSWF("JarisFLVPlayer.swf", "altContentOne", "576px", "360px", "10.0.0", "expressInstall.swf", flashvarsVideo, params, attributes);
swfobject.embedSWF("JarisFLVPlayer.swf", "altContentOne", "750px", "520px", "10.0.0", "expressInstall.swf", flashvarsVideo, params, attributes);
</script>
<style>
html, body { height:100%; }
body { margin:0; }
</style>
</head>
<body>
<br />
<center>
<h3>CTCS三级列控体系介绍</h3>
<div id="altContentOne">
<h1>Jaris FLV Player</h1>
<p>Alternative content</p>
<p><a href="http://www.adobe.com/go/getflashplayer"><img
src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt="Get Adobe Flash player" /></a></p>
</div>
</center>
</body>
</html>
I am trying to use a java application in html5 and javascript, but Chrome always crashes when I try the following:
In the html5 document I have this:
<FORM>
<INPUT type="button" value="call JAVA" onClick = "test()">
</FORM>
<object name="application" type="application/x-java-applet" height="300" width="550" >
<param name="code" value="loader"/>
<param name="java_arguments" value="-Djnlp.packEnabled=true"/>
</object>
In the javascript file I use this function(the onclick test()-function)
function test() {
var app = document.getElementById("applet_test");
alert("Screen Dimension\r\n width:" +
app.getScreenWidth() + " height:" +
app.getScreenHeight() );
}
And finally this is the applet_test.java file:
import java.applet.*;
import java.awt.*;
public class applet_test extends Applet
{ public int getScreenWidth() {
return Toolkit.getDefaultToolkit().getScreenSize().width;
}
public int getScreenHeight() {
return Toolkit.getDefaultToolkit().getScreenSize().height;
}
public void main(String [] args) {
}
}
Does anybody know why this won't work? Eclipse is also complaining about the use of an applet in an html5-document:
Element (applet) is obsolete. Its use is discouraged in HTML5
Could this cause the troubles and if so, how can you get the same result with an element?
This works for me.
<!DOCTYPE html>
<html lang="en"><FORM>
<head>
<script>
function test() {
var app = document.applet_test;
alert("Screen Dimension\r\n width:" + app.getScreenWidth()
+ " height:" + app.getScreenHeight());
}
</script>
<body>
<INPUT type="button" value="call JAVA"
onClick = "test()">
</FORM>
<object name="applet_test" type="application/x-java-applet" height="300" width="550" >
<param name="code" value="loader.class"/>
</object>
</body>
</html>
Change var app = document.getElementById("applet_test"); to
var app = document.applet_test;
Eclipse is also complaining about the use of an applet in an html5-document.
Probably because the applet tag is deprecated. Look at bottom of
https://eyeasme.com/Shayne/HTML5_APPLETS/