mon7610
mon7610

Reputation: 21

assertText a message that has line break in Selenium IDE

I am new in Selenium IDE and need to assertText a value that has line break. Example:

Actual Message to assertText:
Hello
World

store      | Hello <br/> World | txtValue
assertText | id=label          | ${txtValue}

Please help.

Upvotes: 2

Views: 4430

Answers (2)

reiko
reiko

Reputation: 1

Following pattern matching worked for me on Selenium IDE 2.5.0

regexp:Hello\s+World

Upvotes: -1

Falkenfighter
Falkenfighter

Reputation: 588

Pass your id=label into a variable, remove the line breaks, then run an assertion against the variable.

  1. Store expected text:

    store | Hello World | txtValue
    
  2. Store page text:

    storeText | xpath=(//*[@id=label]) | labelValue
    
  3. Remove line breaks from page text:

    echo  | javascript{storedVars.labelValue = storedVars.labelValue.replace(/(\r\n|\n|\r)/gm,"")} | 
    
  4. Assert your expected text = your page text:

    assertExpression | javascript{storedVars.txtValue==storedVars.labelValue} | true
    

Upvotes: 2

Related Questions