0

Could somebody help to understand what is wrong with element searching via Selenide.

I have such HTML code:

<div>
  Current method: 
  <strong>
    SMS
  </strong>
</div>

The Selenium finds the element throw this xpath

findElement(By.xpath("//div[contains(. , \"Current method\")]/strong"))

but Selenide returns ElementNotFound exception with the same locator

$(By.xpath("//div[contains(. , \"Current method\")]/strong"))
Juan Carlos Mendoza
  • 5,736
  • 7
  • 25
  • 50

4 Answers4

1

If you need strong, you can just

   $(By.xpath("//strong[contains(text(),'SMS')]"))
Mzia
  • 406
  • 2
  • 7
  • 21
1

You can us following option. $("strong:contains('SMS')"); Using css selectors method

0

You can try :

$(byText("Current method:")).shouldBe(Condition.exist);
Slavik Muz
  • 1,157
  • 1
  • 15
  • 28
0

Using Selenium-> findElement(By.xpath("//div[contains(text(), 'Current method')]/strong"));

Using Selenide-> $(By.xpath("//div[contains(text(), 'Current method')]/strong"));

These two method can be used in selenium as well as selenide.Methods are not specific to Selenium or selenide