I’ve the next factor 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.change(" ", "${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("Inner")) { 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 factor: Unable to find factor: {"methodology":"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 needs to be handed as a String as a result of I’m utilizing it in a earlier a part of the identical methodology. The worth of the String handed is: “Days Previous Due – (Delay days coming from Host)”.
Thus far, all efforts have failed, with or with out change(), typing the ${nbsp} and or or its u00A0 substitute. So any hints might be extremely appreciated.