0
<div id="content" class="content">
<div class="container col-lg-12 col-md-12 col-sm-12 col-xs-12">
  <div class="alert alert-danger alert-dismissible" role="alert">
    <button class="close" aria-label="Close" data-dismiss="alert" type="button">
      <span aria-hidden="true">×</span>
    </button>
    <strong>Invalid License!</strong>

Please provide xpath for above code. I am not able to find xpath.

Bence Kaulics
  • 1,007
  • 11
  • 21

1 Answers1

3

You've got several options.

The simplest and most obvious (assuming there are no other <strong> elements on the page with the text "Invalid License!") is //strong[text() = "Invalid License!"]

If that fails, I'd start with //div[id = "content"]/div/div/strong[text()="Invalid License!"]

If that proves impossible, I'd try finding the button, going to its parent div, then looking within that div for the <strong> tag.

(Caveat: I am not an xpath expert - this is more of a guide to finding the element you need than completely accurate advice)

Kate Paulk
  • 31,513
  • 8
  • 54
  • 108
  • I am not sure that if #1 would fail there is even a chance to be successful with #2 because #1 includes all the objects including the one that could be returned by query #2. – Alexey R. Nov 14 '18 at 23:11
  • You're likely correct, @AlexeyR. but if the combination of the tag and text is repeated on the page, then query #2 or method 3 would be needed. – Kate Paulk Nov 15 '18 at 12:22