如何使用Laravel Dusk或WebDriverBy在表格的 "textarea "中输入文本?

问题描述 投票:0回答:1
<table>
   <tbody>
      <tr>
         <th scope="row">
           <input type="text" class="form-control">
         </th>

         <th scope="row">
             <textarea rows="8" class="form-control"></textarea>
         </th>
         <th scope="row"></th>
         </tr> 
        <tr>  </tr>
   </tbody>
 </table>

如果我想用laravel dusk在上面的textarea中添加文本, 我如何使用 type() 方法,使用xpath来获取选择器。

我的元素的xpath是。$selector = "//div[@id='__BVID__34']/div/div[2]/table/tbody/tr[1]/th[1]/input";

谁能告诉我如何在类型方法中使用这个选择器?$browser->type('$selector', 'text-to-type');

先谢谢你

laravel xpath types selector
1个回答
0
投票

根据 文档你应该使用一个CSS选择器。在你的情况下(尽量缩短或使用 速记选择器) :

div#__BVID__34 > div > div:nth-of-type(2) > table > tbody > tr:nth-of-type(1) > th:nth-of-type(1) > input

然后你可以使用以下方法之一来输入你的数据。

$browser->type('CSSselector', 'yourtext');
$browser->keys('CSSselector', 'yourtext');
© www.soinside.com 2019 - 2024. All rights reserved.