Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown when ensuring an XPathOrCssTarget has some value #3353

Open
MaxenceBontePE opened this issue Dec 13, 2023 Discussed in #3350 · 0 comments
Open

Exception thrown when ensuring an XPathOrCssTarget has some value #3353

MaxenceBontePE opened this issue Dec 13, 2023 Discussed in #3350 · 0 comments

Comments

@MaxenceBontePE
Copy link

MaxenceBontePE commented Dec 13, 2023

Discussed in #3350

Originally posted by MaxenceBontePE December 8, 2023
Hi,
I have a plain XPathOrCssTarget

public static final Target LIBELLE_COMPETENCE_NUMERO = XPathOrCssTarget
        .the("libellé de la compétence numéro {0}")
        .locatedBy("#competence-clef li:nth-child({0}) .media-body > span > span");

then I use it (in a loop) to remember values

for (int i =0 ; i < CandidatForm.LIBELLE_COMPETENCE.resolveAllFor(actor).size() ; i++) {
    actor.remember("compétence" + i, CandidatForm.LIBELLE_COMPETENCE_NUMERO.of(String.valueOf(i+1)));
}

and then I ensure the same field later has the same value as stored

        for (int i =0 ; i < (int) actor.recall("nb compétences clé") ; i++) {
            actor.attemptsTo(
                Ensure.that(CandidatForm.LIBELLE_COMPETENCE_NUMERO.of(String.valueOf(i+1)))
                    .hasValue(actor.recall("compétence" + i))
            );
        }

but I get the following exception

[ERROR]   class net.serenitybdd.screenplay.targets.XPathOrCssTarget cannot be cast to class java.lang.String (net.serenitybdd.screenplay.targets.XPathOrCssTarget is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')

Did I get something wrong or is this a bug ?
I have penty of Ensures on plain Targets (Target.the("").located(By.something("somethingelse")) having values and recalls and it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant