I’ve the next aspect within the DOM:
And wish to make use of xpath with a purpose to find one of many choices.
The code I’m executing is that this:
searchForLookUpResult(itemName);
clickOnLookUpSearchButton();
System.out.println(driver.findElement(By.xpath("//div[@id='sourceListDiv']/choose/choice")).getText());
itemName = itemName.substitute(" ", "${nbsp}");
System.out.println(itemName);
driver.findElement(By.xpath("//choice[text()="" + itemName + ""]")).click on();
driver.findElement(By.xpath("ui_okButton")).click on();
if (frameContext.equals("Inside")) { switchToFrameManually(1); }
else switchToDialogFrame();
However, it fails when it reaches the:
driver.findElement(By.xpath("//choice[text()="" + itemName + ""]")).click on();
half with the error:
org.openqa.selenium.NoSuchElementException: no such aspect: Unable to find aspect: {"technique":"xpath","selector":"//choice[text()="Days${nbsp}Past${nbsp}Due${nbsp}-${nbsp}(Delay${nbsp}days${nbsp}coming${nbsp}from${nbsp}Host)"]"}
I took the ${nbsp} half from selenium with a purpose to deal with the within the DOM (noticed it right here: https://stackoverflow.com/questions/247135/using-xpath-to-search-text-containing-nbsp)
The itemName parameter must be handed as a String as a result of I’m utilizing it in a earlier a part of the identical technique. The worth of the String handed is: “Days Previous Due – (Delay days coming from Host)”.
To date, all efforts have failed, with or with out substitute(), typing the ${nbsp} and or or its u00A0 substitute. So any hints will probably be extremely appreciated.