Skip to content

Unable to find a xpath in a table #441

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

Open
plmlkrz opened this issue Oct 28, 2022 · 0 comments
Open

Unable to find a xpath in a table #441

plmlkrz opened this issue Oct 28, 2022 · 0 comments

Comments

@plmlkrz
Copy link
Collaborator

plmlkrz commented Oct 28, 2022

Error: invalid selector: Unable to locate an element with the xpath expression sequence number because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string 'sequence number' is not a valid XPath expression.". The issue occurs when attempting to write to a table using an xpath.

Element.java

/**
* Returns the stored XPath for this element.
* Returns null if no XPath exists in the page object.
*
* @return the xPath for the element listed in the page object
*/
public By xPathToBy() {
return By.xpath(selectors.get(SelectorType.XPATH));
}

/**
 * Returns the stored XPath for this element modified to pull the nth instance of the element
 * by using the passing ordinal value (passed as an int).
 *
 * @param ordinal int the instance of the element we want to retrieve
 * @return the xPath for the element listed in the page object for the nth instance (ordinal)
 */
public By xPathToBy(int ordinal) {
	return By.xpath(SentinelStringUtils.format("({})[{}]", selectors.get(SelectorType.XPATH), ordinal));
}
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