Note that there are some explanatory texts on larger screens.

plurals
  1. POSelenium: Is there a way to search the entire page for given keywords?
    primarykey
    data
    text
    <p>I am testing a website very similar to Google. So, if a user entered some search terms like "Selenium Tutorial", the results page would have a bunch of links with snippets. </p> <p>Each result is in a table. So, if there are 10 results, there are 10 tables. For each table (result), there are several rows (say r1, r2, r3, etc). r1 is the title of the result, r2 is the description like size, format, author, etc, and r3 is the snippet. I need to make sure that r3 consits of the word(s) "selenium" "tutorial". I tried doing something like:</p> <pre><code>String variable2 = Sel.GetTable("//div[@id='RepeaterContent']/table[2].3.1"); </code></pre> <p>and this gave me the text in r3, the snippet. But, I need to get the text (snippet) of all tables (results). And perform a search on the snippet afterwards using something like <em>contains</em>. </p> <p>I am not sure if the following code is much helpful because I am unable to copy the source code, but the source of the results page looks something like the following:</p> <pre><code>&lt;HTML&gt; &lt;BODY&gt; &lt;DIV id="RepeaterContent"&gt; &lt;TABLE&gt; &lt;TR&gt; &lt;TD&gt; &lt;SPAN&gt; &lt;a id="linkcft87021" class="ResultList_Title_Link" title="" href="DocsDetail.aspx?searchtranid=1bnt5d92" target=""&gt;Sample Tutorial&lt;/a&gt; &lt;br&gt; &lt;/SPAN&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt; ...an integrated development environment for performing Selenium tests... &lt;/TD&gt; &lt;/TR&gt; &lt;/TABLE&gt; &lt;TABLE&gt; &lt;TR&gt; &lt;TD&gt; &lt;SPAN&gt; &lt;a id="linkcft87021" class="ResultList_Title_Link" title="" href="DocsDetail.aspx?searchtranid=1g5t5d92" target=""&gt;Selenium&lt;/a&gt; &lt;br&gt; &lt;/SPAN&gt; &lt;/TD&gt; &lt;/TR&gt; &lt;TR&gt; &lt;TD&gt; ...With Selenium you can automate the whole process and run the test as required. In this part we will see how to create a simple test in Selenium... &lt;/TD&gt; &lt;/TR&gt; &lt;/TABLE&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>And the following is my selenium test:</p> <pre><code>namespace Automation { [TestClass] public class SEARCH { public ISelenium Sel; public string TestStatus = "FAIL"; // Constructor public LIT_SEARCH_TAB() { Sel = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost:8080"); Sel.Start(); } [TestMethod] public void SEARCH_METHOD() { Sel.Open("http://localhost:8080"); Sel.Type("Search_Text_Box", "Selenium Tutorial"); Sel.Click("Go"); if (Sel.IsTextPresent("Selenium") || (Sel.IsTextPresent("Tutorial"))) { TestStatus = "PASS"; } } } } </code></pre> <p>So, I want to make sure that in the entire results page, there are words "Selenium" and "Tutorial". Is there a way in Selenium that would meet my requirements? Some methods that would search for those keywords in the entire page, and verify the keywords are present? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload