Created
March 30, 2013 21:01
-
-
Save justinedelson/5278313 to your computer and use it in GitHub Desktop.
Geb script which demonstrates how to add a component to a parsys in AEM 5.6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* In this sample Geb script, we are going to add a video component to a page in AEM | |
* using the context menu. | |
* | |
*/ | |
@Grapes([ | |
@Grab("org.codehaus.geb:geb-core:0.7.2"), | |
@Grab("org.seleniumhq.selenium:selenium-chrome-driver:2.31.0"), | |
@Grab("org.seleniumhq.selenium:selenium-support:2.31.0") | |
]) | |
import geb.Browser | |
def username = "admin" | |
def password = "admin" | |
def baseUrl = "http://localhost:4502" | |
Browser.drive { | |
// change to whatever directory you want to save report images to | |
config.reportsDir = new File("/tmp") | |
setBaseUrl(baseUrl) | |
reportGroup "test" | |
cleanReportGroupDir() | |
go "/" | |
report "login-page" | |
// log in to AEM | |
$("#username").value(username) | |
$("#password").value(password) | |
$("button.primary").click() | |
report "after-login" | |
// navigate to a particular page. | |
go "/cf#/content/geometrixx/en/products.html" | |
// ensure that the AEM authoring interface has loaded | |
waitFor(10) { | |
js."CQ.WCM.isSidekickReady() && CQ.WCM.getContentWindow().CQ.WCM.areEditablesReady()" | |
} | |
report "on-page" | |
// the rest of the interactions are done against just the content window frame | |
def contentFrameName = js."CQ.WCM.getContentWindow().name" | |
withFrame(contentFrameName) { | |
def beforeVideoCount = $(".cq-video-placeholder").size() | |
// this is the DOM element for the "Drag components or assets here" element | |
def parNewSection = js."CQ.WCM.getEditable('/content/geometrixx/en/products/jcr:content/par/*').el.dom" | |
interact { | |
moveToElement parNewSection | |
contextClick() | |
} | |
report "after-right-click" | |
// click the New button in the resulting context menu | |
$(".x-menu-item-text", text: "New...").click() | |
report "component menu" | |
// get a handle to the dialog | |
def insertComponentDialog = $(".x-window-header-text", text: "Insert New Component").parents(".x-window") | |
// select the video component from the dialog. This class name is generated by taking the component path and replacing '/' with '_47'. | |
insertComponentDialog.find("button.cq-_47libs_47foundation_47components_47video").click() | |
report "selected-video" | |
// click the OK button | |
insertComponentDialog.find("button", text: "OK").click() | |
report "added-video" | |
assert $(".cq-video-placeholder").size() == (beforeVideoCount + 1) | |
} | |
quit() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment