0

I am unable to find xpath for the below success message:

WebElement successOverlayMsg = findElement(By.xpath("//*[text()='A new app overlay \"APAutomation_Merchant_M32XphDFc\" has been created successfully']"));
if (successOverlayMsg.getText().equals("A new app overlay 'APAutomation_Merchant_MUjL7PDwO' has been created successfully"))
6
  • 2
    It's hard to check your xpath is right or wrong if you don't share the site. But base on your xpath, I'm guessing that it's maybe long text so try: //*[contains(text(),'A new app overlay \"APAutomation_Merchant_M32XphDFc\" has been created successfully')]
    – phong tran
    Nov 21 '19 at 1:43
  • 1
    or try xpath with shorter text: //*[contains(text(),'A new app overlay')]
    – phong tran
    Nov 21 '19 at 1:47
  • Did you try explicit wait ? Try the "contains" method and if it still doesn't work use explicit wait for the text to be present
    – PDHide
    Nov 21 '19 at 7:16
  • And make sure you have only one element that contain the text , else use contains(.,"new overlay") (replace text() with dot)
    – PDHide
    Nov 21 '19 at 7:27
  • 1
    Dude you have different endings for string in quotes ;) Nov 21 '19 at 9:39