Htmlunit access to a frame inside a frameset which is inside a frameset - frame

I need to access to a form element which is in the frame "menu"
<html>
<head>
<script>.........
</script>
<title>The Main page</title>
</head>
<frameset onload="init();" rows="70,*" frameborder="0" border="false" framespacing="0">
<frameset cols="32000,0,0" frameborder="0" border="true" framespacing="0">
<frame scrolling="no" marginheight="0" marginwidth="0" target="logo" src="about:blank" name="logo"></frame>
<frame scrolling="no" noresize="" marginheight="0" marginwidth="0" target="temp" src="about:blank" name="temp"></frame><frame scrolling="no" noresize="" marginheight="0" marginwidth="0" target="system" src="about:blank" name="system"></frame>
</frameset>
<frameset cols="165,*" frameborder="0" border="false" framespacing="0">
<frame scrolling="no" noresize="" marginheight="0" marginwidth="3" target="menu" src="about:blank" name="menu"> </frame>
<frame scrolling="auto" noresize="" marginheight="0" marginwidth="3" target="work" src="about:blank" name="work"></frame>
</frameset>
</frameset>
</html>
I tried this:
menuPage = (HtmlPage)page.getFrameByName("menu").getEnclosedPage();
But what I get is
<?xml version="1.0" encoding="ISO-8859-1"?>
<html>
<head/>
<body/>
</html>
I tried different other odd thing but never succeed to get the content of the frame.....
If somebody have already done this I will be happy to get some clues..

Ok, I found it eventually. The javascript was loading. But besides and most important I was not accessing correctly the frame content. So By looking deeply in the dom with firstchild and sibbling I arrived to see what I was looking for. So the first code working is the following and need some tweaks:
HtmlElement frameset1 = page.getBody();
node = frameset1.getFirstChild().getNextSibling();
HtmlFrame fr1 = (HtmlFrame) node.getFirstChild();
FrameWindow fw1 = (FrameWindow) fr1.getEnclosedWindow();
HtmlPage p1 = (HtmlPage) fw1.getEnclosedPage();
Thanks for your time

Related

frames in selenium pytest

Hi I have parent frame called "bottomframe" inside that have two child frames called "Header" and "Main"
I would like to switch between frames "Header" and "Main" but I am not able to come out from one sub frame.
<iframe id="bottomframe" name="bottomframe" scrolling="yes" src="Home_content.aspx?C=93&L=YTERPIT%40WIN.DESY.DE&sysMsg=0" width="100%" height="100%" align="left"></td></tr></table><input type="hidden" name="iprocure24url" value="https://iprocure.eu1.inforcloudsuite.com/xfel" /></body></html></iframe>
<frameset rows="75,*" bgcolor="lightgrey" border="0"><frame src="punchoutheader.aspx?EvendorKey= 3257" name="Header" marginwidth="0" marginheight="0" width="100%" height="100%" scrolling="no"><frame src="OciPunchOutPage.aspx?EvendorKey= 3257" name="Main" marginwidth="0" marginheight="0" width="100%" height="100%"></frameset>
<frame src="punchoutheader.aspx?EvendorKey= 3257" name="Header" marginwidth="0" marginheight="0" width="100%" height="100%" scrolling="no">
</frame>
<frame src="OciPunchOutPage.aspx?EvendorKey= 3257" name="Main" marginwidth="0" marginheight="0" width="100%" height="100%">
</frame>
</frameset>
</iframe>
I tried below in pytest with selenium
driver.switch_to.frame("bottomframe")
driver.switch_to.frame("Header")
bodyText = driver.find_element_by_tag_name('body').text
print(bodyText)
This above works fine but now I would like to switch to another subframe "Main" so I tried below
driver.switch_to.frame("bottomframe")
driver.switch_to.frame("Header")
bodyText = driver.find_element_by_tag_name('body').text
print(bodyText)
# back to default web page frame
driver.switch_to.default_content()
driver.switch_to.frame("bottomframe")
driver.switch_to.frame("Main")
and i get NoSuchFrameException if I go to "Main" frame.
Could you help me out to switch between frames "Main" and "Header"
A good approach
A better way to switch frames will be to induce WebDriverWait for the availability of the intended frame with expected_conditions set to frame_to_be_available_and_switch_to_it as follows
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.NAME,"Main")))
OR
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//frame[#name='Main']")))
Switching back from frame
To switch back to the Parent Frame you can use the following line of code:
driver.switch_to.parent_frame()
To switch back to the Top Level Browsing Context / Top Window you can use the following line of code:
driver.switch_to.default_content()

Selenium switchTo frame using Frameset

<frameset border="0" rows="25,*" frameSpacing="0" frameBorder="0" onbeforeunload="doUnload()" onunload="doUnload()" onkeydown="fn_KeyDown(event)">
<frame name="link" scrolling="no" src="Links.aspx?FromWhere=DB" marginwidth="0" marginheight="0" BORDER="0" target="_self">
<script >
alert('');</script>
<frame id="Sub" src="../Home/Home.aspx?FromWhere=DB" scrolling="Yes" name="Sub" >
</frameset>
How to switchto the frame here and perform operations in selenium?
If you want to switch to first frame driver.switchTo().frame(driver.findElement(By.cssSelector("frame[name='link']")));
If you want to switch to the Second frame with name 'Sub'
driver.switchTo().frame(driver.findElement(By.cssSelector("frame[name='Sub']")));
or
driver.switchTo().frame(driver.findElement(By.cssSelector("frame#Sub")));

Primefaces dynamic dialog with ui:include not working after PF upgrade from 4.0 to 5.1 [duplicate]

This question already has answers here:
How to include another XHTML in XHTML using JSF 2.0 Facelets?
(2 answers)
Closed 8 years ago.
I've recently upgraded Primefaces from 4.0 to 5.1 and after that dialogs are not being shown after clicking the commandButton. It works with dynamic="false" but I need it to be lazy loaded. ExampleBean is sessionScoped and i'm using JSF 2.2. Can someone help me solve this?
<ui:composition template="/template/common/pagelayout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:ez="http://xmlns.jcp.org/jsf/composite">
<ui:define name="content">
<h:form id="form">
<p:commandButton type="button" value="Log" onclick="PF('dlgLog').show();" icon="botaoLog" />
</h:form>
<p:dialog header="HEADER" widgetVar="dlgLog" resizable="false" modal="true" height="500" width="1000" dynamic="true">
<ui:include src="logPage.xhtml"/>
</p:dialog>
</ui:define>
</ui:composition>
logPage.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form id="formlog">
<p:dataTable var="log" value="#{exampleBean.logs}" emptyMessage="Empty">
<p:column headerText="Header1" width="10%">
<h:outputText value="#{log.date}">
<f:convertDateTime pattern="dd/MM/yyyy - HH:mm"/>
</h:outputText>
</p:column>
<p:column headerText="Header2" width="10%">
<h:outputText value="#{log.op}" />
</p:column>
<p:column headerText="Header3">
<p:outputLabel value="#{log.name}"/>
</p:column>
</p:dataTable>
</h:form>
</h:body>
</html>
More specifically, you removed the h:head tag (and I found out ;-). Between the versions you used, PF created it's own h:head renderer which differs from the default implementions in code jsf libraries hence the difference in behaviour (assuming your jsf impl stayed the same).
Finally figured what the problem was. Just removed the <h:head> tag from logPage.xhtml and it worked! Not sure I know the reason though, probably has something to do with <ui:include> expecting a composition which shouldn't have a <h:head> tag.

Google+ plus post with video embedded via PHP

I want to share a link on google+ which will have embedded video when shared as post
Here are the relevant open graph tags that are being used
<meta property="og:type" content="website" />
<meta property="og:url" content="http://mysiteurl" />
<meta property="og:image" content="http://imageurl" />
<meta property="og:description" content="desc goes here />
<meta property="og:title" content="title goes here" />
<meta property="og:site_name" content="sitename" />
<meta property="og:video" content="https://www.youtube.com/v/XXXXXX" />
<meta property="og:video:width" content="300" />
<meta property="og:video:height" content="200" />
<meta property="og:video:type" content="application/x-shockwave-flash" />'
I am using
<a title="Google plus" href='https://plus.google.com/share?url=http%3A%2F%2Fmysiteurl'><img src='/images/googleshare.png'></a>
for sharing via php.
Google plus is picking everything from open graph except video. Do I need to do something else to share this link with video embedded?
Google+ has a small whitelist of sites they embed video from. You are not on the whitelist so video previews won't work. Google does not have a formal process for getting on the whitelist.

How do I make resizers update the item position in XUL?

I have the following code, where a button has four resizers. When I use the top left resizer for example, it button shrinks from the bottom right, as opposed to shrinking and moving so that the top left corner follows the cursor. I've looked in Mozilla's docs and on Google, and tried adding custom on mousedown event handlers to move the thing around - but to no avail. How do I make this behave correctly?
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="My App" width="300" height="300" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://ades/content/main.js"/>
<hbox>
<stack style="padding: 0;">
<button id="b" label="Resizable" style="margin: 0;"/>
<resizer dir="topleft" style="background: red; -moz-appearance: none;"
element="b" left="0" top="0" width="5" height="5" />
<resizer dir="topright" style="background: black; -moz-appearance: none;"
element="b" right="0" top="0" width="5" height="5"/>
<resizer dir="bottomleft" style="background: black; -moz-appearance: none;"
element="b" left="0" bottom="0" width="5" height="5"/>
<resizer dir="bottomright" style="background: black; -moz-appearance: none;"
element="b" right="0" bottom="0" width="5" height="5"/>
</stack>
</hbox>
</window>
I'm not sure how to achieve what you want but if you're resizing your button it will always reposition itself in the stack (which is at the beginning of the hbox), so it will always be at the beginning of the hbox. You might try with absolute positioning but I'm not sure if that'll work either.