2

I am verifying text using these Xpaths,

    $I->CanSeeElement("//tbody[contains(tr/td/div/table/tbody/tr/td[1]/text(),$this->Secondarycustomer)]");
    $I->CanSeeElement("//tbody[contains(tr/td/div/table/tbody/tr/td[2]/text(),$this->custfileruleid2)]");
    $I->CanSeeElement("//tbody[contains(tr/td/div/table/tbody/tr/td[3]/text(),$this->RuleName2)]");

When I update my db these rows above are no longer there and I want to verify that is true. I have tried using my framework to NOT see those xpaths but it breaks, I notice they don't exist anymore and I am left with:

<td width="49%">
    <table class="scollable dashboard">
        <tbody>
           <tr>
             <td>
               <div class="scrollArea">
             </td>
          </tr>
       </tbody>
     </table>
 </td>

Any help is appreciated!

  • Was the div there before you deleted those rows? – user246 Mar 8 '16 at 19:37
  • yes the div was there – kapperkp Mar 8 '16 at 19:41
  • Is that Selenium/WebDriver with PHP? Also, do you want to verify that specific rows are no longer there, or that the table is empty except for the row with the div in it? – user246 Mar 8 '16 at 19:47
  • yes codeception framework in PHP. My first attempt was to do the opposite of "CanSeeElement" on the xpaths provided to no avail, just gives me an failed asserting that an array is empty. Now id like to just verify that the table has no rows – kapperkp Mar 8 '16 at 19:54
  • According to the documentation, this should work: $I->dontSeeElement('.error') – FDM Mar 8 '16 at 20:08
1

You can check presence of /td or /tr tag in certain table with XPath. Do remember, that thead can have /td as well.

If the table XPath is

//table/tbody

then XPath of each row is

//table/tbody/tr

and Xpath of any field could be

//table/tbody/descendant::td

Additionally, you should not test it for visibility, but for presence in DOM. Visibility functions usually throw an exceptions if there is null (element is not even present). So better check the presence of the object regardless it is visible or not.

From your question it is not clearly visible what API and Language you are using. Probably PHP, but I'm not an expert in this field.

4

The Java Webdriver API has two methods for locating elements: findElement and findElements. findElement returns a single element matching the specified criteria (and otherwise throws an exception). findElements returns a list of matching elements, or otherwise an empty list. With the Java API, you would solve the problem by calling findElements and then verifying that the matching count is zero.

Perhaps you could do the same thing with the API you are using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.