Forum Discussion

pavak's avatar
pavak
Occasional Contributor
9 years ago
Solved

test Search by keyword functionality

I need to test "Search by keyword" functionality. Can someone please help me with that.

Ex: If I search by keyword "abc", i am expecting "abc" in response for 10 times by default.(which we can change it to 100)

Please let me know if you need any other information.

Appreciate it.

 

- Pavak Shah

  • Ok, you can try xpath assertion something like:
    xpath expression as count(//subtag4[contains(.,'abc')]) and provide the expected value

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    There is an Contains assertion, but that may not give you how many times the string matched. In order to do that you may do this :
    Convert the response into string then do pattern match which may you desired result and you may also count the times dynamic.
    • pavak's avatar
      pavak
      Occasional Contributor

      Thank you Rao.

      I am expecting my keyword response in one perticular tag.(Not anywhere in response).

      Here is the example of how much response may look like.

      Request: "abc"

       

      Response: <tag1>xyz</tag1>

                            <subtag1>test</subtag1>

                            <subtag2>test1</subtag2>

                            <subtag3>test2</subtag3>

                            <subtag4>abc</subtag4>

                            <subtag5>test3</subtag5>

                       <tag1>pqr</tag1>

                            <subtag1>test4</subtag1>

                            <subtag2>test5</subtag2>

                            <subtag3>test6</subtag3>

                            <subtag4>abcdef</subtag4> //as you see here this tag contains "abc" in "abcdef" 

                            <subtag5>test7</subtag5>

      ..... So on n so forth for 10 times. I need to make sure I get "abc" in subtag 4 which may contains some other words as well.

      Hope my example is helpful.

       

      • nmrao's avatar
        nmrao
        Champion Level 3
        Ok, you can try xpath assertion something like:
        xpath expression as count(//subtag4[contains(.,'abc')]) and provide the expected value