1

I am using Selenium IDE in FireFox.

I want to write an IF statement that will search through all text() on page, if it finds matching text echo "Found it", else echo "not found".

Where I have got so far:

*somehow search here hopefully Stackoverflow save the day* store | FOUND IT | found store | NOT FOUND | notfound if | ${test}==true | echo | ${found} | else | | echo | ${notfound} | endIf | | 

Please do not give me JavaScript code etc..., I am using the FireFox addon IDE.

Thank you!

3
  • This is a possible duplicate of stackoverflow.com/questions/14974508/… Commented Jul 1, 2016 at 14:17
  • @JosephEvans That doesn't use the Selenium IDE Commented Jul 1, 2016 at 14:18
  • 1
    Let's start of with saying that I don't have a clue how to write scripts for Selnium IDE. I do know that in the plugin there is an option assertBodyText(pattern). This will check if the passed pattern is in the page source which seems to be exactly what you want. Commented Jul 1, 2016 at 14:20

2 Answers 2

1

You can use this script.

storeText | css=body | text storeEval |javascript{storedVars['text'].indexOf("Find me",0) > 0} | find if | ${find}==true | echo | FOUND IT| else | | echo | TEXT NOT FOUND | endIf | | 

In the sample, I stored all the text in the page body using the text variable then I used a javascript code to locate the Find me text in the variable. This is guaranteed working in Selenium IDE. Let me know if you have any more questions.

Sign up to request clarification or add additional context in comments.

Comments

0

Answer by Rodel is correct. But there is the way to make it in just one step.

echo | javascript{if (document.documentElement.innerHTML.indexOf('Text_to_find') > 0) {'Found'} else {'Not Found'}} 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.