use of com.wikia.webdriver.common.core.elemnt.JavascriptActions in project selenium-tests by Wikia.
the class PageObjectLogging method afterNavigateTo.
@Override
public void afterNavigateTo(String url, WebDriver driver) {
StringBuilder builder = new StringBuilder();
if (!AlertHandler.isAlertPresent(driver)) {
if (url.equals(driver.getCurrentUrl())) {
builder.append("<tr class=\"success\"><td>Url after navigation</td><td>" + "<a href='" + driver.getCurrentUrl() + "'>" + driver.getCurrentUrl() + "</a></td><td> <br/> </td></tr>");
CommonUtils.appendTextToFile(logPath, builder.toString());
} else {
if (driver.getCurrentUrl().contains("data:text/html,chromewebdata ")) {
driver.get(url);
}
logWarning("Url after navigation", driver.getCurrentUrl());
}
} else {
logWarning("Url after navigation", "Unable to check URL after navigation - alert present");
}
if (driver.getCurrentUrl().contains(Configuration.getWikiaDomain())) {
// HACK FOR DISABLING NOTIFICATIONS
try {
new JavascriptActions(driver).execute("$(\".sprite.close-notification\")[0].click()");
} catch (WebDriverException e) {
}
/**
* We want to disable sales pitch dialog for new potential contributors to avoid hiding other
* UI elements. see https://wikia-inc.atlassian.net/browse/CE-3768
*/
if ("true".equals(Configuration.getDisableCommunityPageSalesPitchDialog())) {
driver.manage().addCookie(new Cookie("cpBenefitsModalShown", "1", Configuration.getWikiaDomain(), null, null));
}
if (TestContext.isFirstLoad() && "true".equals(Configuration.getMockAds())) {
driver.manage().addCookie(new Cookie("mock-ads", XMLReader.getValue("mock.ads_token"), String.format(".%s", Configuration.getEnvType().getWikiaDomain()), null, null));
}
}
Method method = TestContext.getCurrentTestMethod();
Class<?> declaringClass = method.getDeclaringClass();
if (TestContext.isFirstLoad()) {
User user = null;
TestContext.setFirstLoad(false);
if (declaringClass.isAnnotationPresent(Execute.class)) {
user = declaringClass.getAnnotation(Execute.class).asUser();
}
if (method.isAnnotationPresent(Execute.class)) {
user = method.getAnnotation(Execute.class).asUser();
}
if (user != null && user != User.ANONYMOUS) {
// log in, make sure user is logged in and flow is on the requested url
new WikiBasePageObject().loginAs(user);
}
}
logJSError(driver);
}
use of com.wikia.webdriver.common.core.elemnt.JavascriptActions in project selenium-tests by Wikia.
the class PageObjectLogging method beforeNavigateTo.
@Override
public void beforeNavigateTo(String url, WebDriver driver) {
new JavascriptActions(driver).execute("window.stop()");
StringBuilder builder = new StringBuilder();
builder.append("<tr class=\"success\"><td>Navigate to</td><td>" + "<a href='" + url + "'>" + url + "</a></td><td> <br/> </td></tr>");
CommonUtils.appendTextToFile(logPath, builder.toString());
logJSError(driver);
}
use of com.wikia.webdriver.common.core.elemnt.JavascriptActions in project selenium-tests by Wikia.
the class LightboxTests method mercury_lightbox_PreserveScrollPositionAfterLightboxOpen.
@Test
public void mercury_lightbox_PreserveScrollPositionAfterLightboxOpen() {
ArticlePage articlePage = new ArticlePage().open("/LightboxTest");
articlePage.getLightbox().openLightboxImage(0);
Long startingPosition = new JavascriptActions().getCurrentPosition();
articlePage.getLightbox().clickCloseButton();
Long closingPosition = new JavascriptActions().getCurrentPosition();
Assertion.assertEquals(startingPosition, closingPosition, "Starting scroll position should be " + "the same as closing position");
Assertion.assertTrue(startingPosition > 0 && closingPosition > 0, "Page shoudln't be scrolled" + "to top");
}
use of com.wikia.webdriver.common.core.elemnt.JavascriptActions in project selenium-tests by Wikia.
the class TestAdsBrowserError method adsScrollHandlerBrowserError.
@Test(groups = "AdsScrollHandlerBrowserError")
public void adsScrollHandlerBrowserError() {
JavascriptActions jsActions = new JavascriptActions(driver);
String testPage = urlBuilder.getUrlForPath("project43", "SyntheticTests/UAP");
testPage = urlBuilder.appendQueryStringToURL(testPage, "scrollhandler=1");
AdsBaseObject adsBaseObject = new AdsBaseObject(driver);
adsBaseObject.getUrl(testPage);
jsActions.addErrorListenerScript();
jsActions.waitForJavaScriptTruthy("window.scrollY == 0");
jsActions.scrollBy(0, 5001);
jsActions.waitForJavaScriptTruthy("window.scrollY != 0");
Assertion.assertEquals(jsActions.getWindowErrors(), "");
}
use of com.wikia.webdriver.common.core.elemnt.JavascriptActions in project selenium-tests by Wikia.
the class NavigationMercuryTests method mercury_navigation_scrollPositionPreservedAfterNavigatingBack.
@Test
public void mercury_navigation_scrollPositionPreservedAfterNavigatingBack() {
ArticlePage testPage = new ArticlePage().open("/ScrollPreserveTest");
Long firstPosition = testPage.scrollToLink(0, 200);
testPage.clickArticleLink(0);
driver.navigate().back();
Long secondPosition = new JavascriptActions().getCurrentPosition();
Assertion.assertEquals(firstPosition, secondPosition, "Scroll position should be preserved " + "after navigating back");
Assertion.assertTrue(firstPosition > 0 && secondPosition > 0, "Page shoudln't be scrolled " + "to top");
}
Aggregations