Skip to content

Commit

Permalink
Remove all assertText methods from Page
Browse files Browse the repository at this point in the history
  • Loading branch information
martingrossmann committed Sep 23, 2024
1 parent 0268bca commit 74d8850
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
package eu.tsystems.mms.tic.testframework.pageobjects;

import eu.tsystems.mms.tic.testframework.common.Testerra;
import eu.tsystems.mms.tic.testframework.exceptions.ElementNotFoundException;
import eu.tsystems.mms.tic.testframework.internal.Nameable;
import eu.tsystems.mms.tic.testframework.internal.asserts.PropertyAssertionConfig;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.AbstractPage;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.DefaultPageAssertions;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.PageUiElementFinder;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.asserts.PageAssertions;
import eu.tsystems.mms.tic.testframework.report.Report;
import eu.tsystems.mms.tic.testframework.utils.TimerUtils;
import org.openqa.selenium.WebDriver;

/**
Expand Down Expand Up @@ -125,17 +123,6 @@ public WebDriver getWebDriver() {
// TimerUtils.sleep(timeToWait);
// }

/**
* Waits for a text to be not present.
*
* @return boolean true if success == text is not present. false otherwise.
*/
@Deprecated
public boolean waitForIsNotTextPresentWithDelay(final String text, final int delayInSeconds) {
TimerUtils.sleep(delayInSeconds * 1000);
return waitForIsNotTextPresent(text);
}

protected UiElementFinder getFinder() {
return this.finder;
}
Expand All @@ -150,86 +137,13 @@ protected UiElement findDeep(Locator locator) {
return getFinder().findDeep(locator);
}

/**
* Waits for a text to be not present.
*
* @return boolean true if success == text is not present. false otherwise.
*/
@Deprecated
public boolean waitForIsNotTextDisplayedWithDelay(final String text, final int delayInSeconds) {
TimerUtils.sleep(delayInSeconds * 1000);
return waitForIsNotTextDisplayed(text);
}

@Override
protected void pageLoaded() {
if (Testerra.Properties.SCREENSHOT_ON_PAGELOAD.asBool()) {
this.screenshotToReport();
}
}

/**
* Waits for a text to be not present.
*
* @return boolean true if success == text is not present. false otherwise.
*/
@Deprecated
public boolean waitForIsNotTextPresent(final String text) {
return anyElementContainsText(text).waitFor().present(false);
}

/**
* Waits for a text to be not displayed.
*
* @return boolean true if success == text is not present. false otherwise.
*/
@Deprecated
public boolean waitForIsNotTextDisplayed(final String text) {
return anyElementContainsText(text).waitFor().displayed(false);
}

@Deprecated
public void assertIsTextPresent(String text, String description) {
assertIsTextPresent(text);
}

@Deprecated
public void assertIsTextDisplayed(String text, String description) {
assertIsTextDisplayed(text);
}

@Deprecated
public void assertIsTextPresent(String text) {
anyElementContainsText(text).expect().present().is(true);
}

@Deprecated
public void assertIsTextDisplayed(String text) {
anyElementContainsText(text).expect().displayed().is(true);
}

@Deprecated
public void assertIsNotTextPresent(String text) {
anyElementContainsText(text).expect().present().is(false);
}

@Deprecated
public void assertIsNotTextDisplayed(String text) {
try {
anyElementContainsText(text).expect().displayed().is(false);
} catch (AssertionError error) {
if (error.getCause() instanceof ElementNotFoundException) {
// ignore this
} else {
throw error;
}
}
}

private TestableUiElement anyElementContainsText(String text) {
return this.getFinder().findDeep(XPath.from("*").text().contains(text));
}

@Override
public PageAssertions waitFor(int seconds) {
PropertyAssertionConfig config = new PropertyAssertionConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
import eu.tsystems.mms.tic.testframework.pageobjects.Page;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.asserts.DefaultImageAssertion;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.asserts.DefaultRectAssertion;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.asserts.DefaultUiElementAssertion;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.asserts.PageAssertions;
import eu.tsystems.mms.tic.testframework.pageobjects.internal.asserts.RectAssertion;
import eu.tsystems.mms.tic.testframework.report.Report;
import eu.tsystems.mms.tic.testframework.report.model.context.Screenshot;
import eu.tsystems.mms.tic.testframework.report.utils.ExecutionContextController;
import eu.tsystems.mms.tic.testframework.utils.JSUtils;
import eu.tsystems.mms.tic.testframework.utils.UITestUtils;
import java.io.File;
import java.util.concurrent.atomic.AtomicReference;
import org.openqa.selenium.Rectangle;
import org.openqa.selenium.WebDriver;

import java.io.File;
import java.util.concurrent.atomic.AtomicReference;

public class DefaultPageAssertions implements PageAssertions {
private static final PropertyAssertionFactory propertyAssertionFactory = Testerra.getInjector().getInstance(PropertyAssertionFactory.class);
private static final Report report = Testerra.getInjector().getInstance(Report.class);
Expand All @@ -69,7 +69,7 @@ public String getActual() {

@Override
public String createSubject() {
return Format.separate(page.toString(), "title="+Format.shortString(getActual()));
return Format.separate(page.toString(), "title=" + Format.shortString(getActual()));
}
});
}
Expand All @@ -84,7 +84,7 @@ public String getActual() {

@Override
public String createSubject() {
return Format.separate(page.toString(), "url="+Format.param(getActual()));
return Format.separate(page.toString(), "url=" + Format.param(getActual()));
}
});
}
Expand All @@ -101,6 +101,7 @@ public Boolean getActual() {
return false;
}
}

@Override
public String createSubject() {
return Format.separate(page.toString(), "displayed");
Expand All @@ -120,6 +121,7 @@ public Boolean getActual() {
return false;
}
}

@Override
public String createSubject() {
return Format.separate(page.toString(), "present");
Expand Down

This file was deleted.

Empty file.

0 comments on commit 74d8850

Please sign in to comment.