Is it possible to combine these two Xpaths into one xpath query?
signatureAgreementThumbnailForInProgressApplication = By.XPath("//div[text()='Upload Signature Agreement']/parent::div/parent::div/descendant::div[contains(@style,'background-image: url')]");
signatureAgreementThumbnailForSubmittedApplication = By.XPath("//div[text()='Signature Agreement']/parent::div/descendant::div[contains(@style,'background-image: url')]");
My automation test (project is VS/C#/Selenium) requires validating the presence (but not content or anything else) of document thumbnails for two statuses of an online application: in-progress and submitted. I feel two separate methods with different xpaths is redundant, since I am doing the same simple validation.
After looking through SO posts which suggested using and/or to evalute multiple attributes, I created this below query which works almost perfectly for both In-Progress and Submitted thumbnails. Minor issue is that for Submitted, in DOM, the xpath hits two thumbnail elements, the one I want it to hit and another one. My test still passes since it is validating thumbnail presence, but I am hoping to tweak it so it finds the specific thumbnail.
signatureAgreementThumbnail = By.XPath("//div[text()='Upload Signature Agreement' or text()='Signature Agreement']/parent::div/parent::div/descendant::div[contains(@style,'background-image: url')]");
I also tried the following queries, which do not work at all:
//div[text()='Upload Signature Agreement' or text()='Signature Agreement'][/parent::div/parent::div/descendant::div or /parent::div/descendant::div][contains(@style,'background-image: url')]
//div[text()='Upload Signature Agreement' or text()='Signature Agreement'][/parent::div/parent::div/descendant::div or /parent::div/descendant::div and contains(@style,'background-image: url')]
I cannot provide the URL of the site I am automating since it is a private site.