1

I have tried this,

//label[text()='Legal Business Nam (you can add a DBA after your account is open )']

//label[text()='Legal Business Name' and '(you can add a DBA after your account is open )']

but does not work.

<div class="form-group col-md-12"><label>Legal Business Name (you can add a DBA after your account is open )</label><input type="text" class="form-control required" placeholder="Enter legal business name" name="company_name" maxlength="250" value=""><label id="company_name-error" class="help-block text-danger validation-error" for="company_name"></label></div>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
kunal soni
  • 585
  • 1
  • 7
  • 19
  • Please read why a [screenshot of HTML or code or error is a bad idea](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). Consider updating the Question with formatted text based relevant HTML, code trials and error stack trace. – undetected Selenium Aug 05 '20 at 08:45
  • Let me add HTML code. Done, please check – kunal soni Aug 05 '20 at 08:45

2 Answers2

2

You can try to use . instead of text().

//label[contains(., 'Legal Business Name (you can add a DBA after your account is open )')]

Or just join 2 [contains(text(), '')] statements like this:

//label[contains(text(), 'Legal Business Name ')][contains(text(), '(you can add a DBA after your account is open )')]
Fenio
  • 3,528
  • 1
  • 13
  • 27
0

Seems you were close enough. Instead of text() you need to use contains() as follows:

//label[contains(., 'you can add a DBA after your account is open')]

Ideally, you have to induce WebDriverWait for the visibilityOfElementLocated() and you can use the following based Locator Strategy:

new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[contains(., 'you can add a DBA after your account is open')]")))
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352