VBA code to trigger an iframe div class element - vba

Please help me with the below IE automation scenario,
I need a vba code to click on a web page label text (Log an Issue) which has been placed inside an iframe, the sample html code is given below,
<iframe name="VF304274040_1502270092884IF_1" title="Browse Categories" id="VF304274040_1502270092884IF_1" src="javascript:"<HTML></HTML>"" frameBorder="0" scrolling="auto" style="background-color: transparent; width: 100%; height: 100%; top: 0px; left: 0px;" allowTransparency="allowtransparency" onload="F(1,304274040).ol()" arviewbordercolor="null">
<head>XXXX
<body>XXXX
<div id XXXX>
.............
<div id XXXX>
......
<div>
<div class="categoryTitleLink">
<label class="cursor bold category_title" id="cat-title IDHAA5V0GQBL2AN3HRTMFOSP0OLB90" level="0" category="true" categoryname="Log+an+Issue" descr="#IDHAA5V0GQBL2AN3HRTMFOSP0OLB90" jQuery15019202206560111384="9">
....Text - Log an Issue
</body></head>
I've tried the below vba code to parse through the iframe and it's div class inner texts and found the "Log an Issue" element, but i couldn't trigger it.
VBA code:
doc1 = IE.document.frames(1).Name
For Each div In IE.document.frames(doc1).document.getElementsByTagName("div")
class_obj = div.innerText
If class_obj = "Log an Issue" Then ' the text was found by this loop
div.parentElement.Click ' this doesn't works (nothing happening)
End If
Next div
Please help!!

Try
doc1 = IE.document.frames(1).Name
IE.document.frames(doc1).document.getElementId("cat-title IDHAA5V0GQBL2AN3HRTMFOSP0OLB90").Click
The element has an id so try using it.

Related

Settling in HTMX

I'm trying to use a CSS transition in a similar manner to https://htmx.org/examples/bulk-update/ to show which row was updated, but I can't get it to work for my example using HTMX 1.3.3
The relevant HTML is:
<div id="replace-me">
<div id="A" hx-get="/A" hx-target="#replace-me" hx-select="#replace-me" hx-swap="outerHTML">A</div>
<div id="B" hx-get="/B" hx-target="#replace-me" hx-select="#replace-me" hx-swap="outerHTML">B</div>
</div>
When either div A or div B is clicked, the server returns the above HTML again, but with class="updated" applied to the div in question.
I also have the following CSS:
.htmx-settling .updated {
background: darkseagreen;
}
.updated {
border: 1px solid black;
}
I would expect to see the clicked div show a border and also flash green. However what I observe is:
I click on div A.
div A shows a border but does not flash.
I click on div B.
div B shows a border, but div A flashes.
From then on, the div that I click on shows a border, but the div that was clicked on the previous turn flashed.
I'm guessing this is something to do with the timing of the application/removal of the htmx-settling class combined with when the swapped content gains the new class. I've read https://htmx.org/docs/#request-operations and https://htmx.org/docs/#css_transitions, but can't see where I'm going wrong.
AFIAK you need transition in you CSS, like from https://htmx.org/docs/#css_transitions
.red {
color: red;
transition: all ease-in 1s ; <========= missing?
}

Is there any function in selenium to input text in field which is not visible using java?

Enter text in ABSTRACT TILE filed using send keysI'm trying to input text in ABSTRACT_TITLE using send-keys in selenium.
I tried switching frames and giving input.
<div id="reTitleCenter" class="reContent" style="height: 2.91667em;" xpath="1">
<label for="reTitleContentHiddenTextarea" style="display:none;">RadEditor hidden textarea</label>
<textarea id="reTitleContentHiddenTextarea" name="ctl00$ctl00$ctl00$phDesktop$cphContent$cphContent$reTitle" rows="4" cols="20" style="display:none;"></textarea>
<iframe frameborder="0" src="javascript:'<html></html>';" id="reTitle_contentIframe" title="Rich text editor with ID reTitle" style="width: 100%; height: 100%; margin: 0px; padding: 0px;">Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>
<textarea class="reTextArea reTextAreaHidden"></textarea>
</div>
the code samples I tried -
driver.switchTo().frame("reTitle");
driver.findElement(By.xpath("//div[#id='reTitleTop']/div[#class='RadEditor_Bootstrap reToolBarWrapper']")).click();
driver.findElement(By.xpath("//div[#id='reTitleTop']/div[#class='RadEditor_Bootstrap reToolBarWrapper']")).sendKeys("This is demo abstract");
OR
driver.switchTo().defaultContent();
WebElement Abstract_title = driver.findElement(By.xpath("//html//body"));
Abstract_title.sendKeys("This is abstract demo selenium");
OR
selenium.SelectFrame("xpath_of_iframe"); (Don't know how to use it)
selenium.Type("//html/body","Thank you");

How to add a watermark image to Qweb Reports in all PDF pages in Odoo?

I am creating qweb report and I want to add a image to the background in all pages but I am getting watermark in only the first page. What I have tried:
<div style="position:absolute;text-align:center;z-index:-1;border:0;opacity:0.1;padding-top:50px;">
<img t-att-src="'data:image/png;base64,%s' %o.employee_id.company_id.watermark_img"/>
</div>
I have found the solution here
Add this code for watermark in header of external layout. Its external id is report.external_layout_header:
<style>
.watermark {
position: absolute;
opacity: 0.25;
z-index: 1000;
transform: rotate(300deg);
-webkit-transform: rotate(300deg);
width: 150%;
}
</style>
<div class="watermark">
<p>WATERMARK</p>
<img t-att-src="'/module_name/static/src/img/image_name.png'" />
</div>
I have added a image stored as a file. If you are going to use a static image I think this is the most appropiate way
Note: I am afraid this does not work in Odoo v11
Update
This solution only is valid if you want to add the same image to all the reports.
There is a module developed by the OCA to add watermarks to the reports. A field appears in all reports where an images (with A4 size) can be added. The module name is report_qweb_pdf_watermark
Please try this code:
<div
style="position:absolute;opacity:0.25;z-index:1000;transform:rotate(300deg);-webkit-transform:rotate(300deg);width:150%;">
<p style="font-size:50px;">WATERMARK TEXT</p>
</div>

Not able to validate a Popup Overlay in my application

I am using Selenium webdriver using Cucumber.
I have clicked a button which open up a popup box, containing few web elements within it. I need to perform few validations in this pop up box. But once the overlay popup is displayed, I am not able to validate it using isDisplayed.
In the console, it display a Error message - java.lang.NullPointerException but I am not passing any value in any variable to validate this popup box.
My script is as below:
public static void Popupbox() {
searchbox = (Application_Pagexpath.popupboxheader).isDisplayed();
try{
Thread.sleep(100);
}catch(InterruptedException e){
e.printStackTrace(); }
if(searchbox = True) {
System.out.println("Popup is displayed"); }
}
The xpaths I am using are correct and these work fine in the firebug. Can you help me understand why I am seeing the Null pointer exception error and why Selenium is not able to validate this overlay popup.
The HTML for the overlay popup is as below:
div id="_paymentHistoryPortlet_WAR_EBillingWebportlet_:paybillHtyForm:dvAdvSearchOverlay" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ebillingAdvFltrOverlay ui-draggable ui-overlay-visible" style="width: auto; height: auto; left: 227.7px; top: 0px; visibility: visible; z-index: 1001;" role="dialog" aria-labelledby="_paymentHistoryPortlet_WAR_EBillingWebportlet_:paybillHtyForm:dvAdvSearchOverlay_title" aria-hidden="false" aria-live="polite"
div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top"
div class="ui-dialog-content ui-widget-content" style="height: auto;"

Selenium Webdriver C# : Need help accessing the Elements inside iFrame

I am having an iFrame inside an overlayWindow and not able to access the iFrame and its element. I have lots of Menus inside the iFrame and need to test that.
The html code looks like below:
<div class="exp overlayContainer" style="">
<div class="overlayBackground"></div>
<div class="overlayWindow" style="position: absolute;">
<div class="overlayWindowInner" style="top: 30px; left: -410px;">
<div id="closetab">
<iframe class="overlayWindowContent" frameborder="0" src="/Templates/frame_loading.html?/my-exp/pers...
I am currently using the below selenium code to locate the iFrame
IWebElement detailFrame = driver.FindElement(By.XPath("//iframe[#class='overlayWindowContent']"));
driver.SwitchTo().Frame(detailFrame);
but getting the below error message.
frameElement cannot be converted to RemoteWebElement
Let me know with your comments
I had same problem and I used driver.switchTo().frame(0); and it worked fine for me.