CSS选择器 - 内部文本

内部文本是HTML标记在网页上显示的字符串模式。

语法: css = <HTML tag> <:> <contains> <(“内部文本”)>
: - 用于表示包含方法。
例如,要测验登录页面的“登录”提交按钮定义CSS选择器定位如下:css=button:contains("Login")

单击“在页面中查找目标”按钮,检查定义的CSS选择器是否找到所需的元素。

下面是登录页面的代码(index.php ) -

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <title>Selenium示例™ - 许虎虎</title>
 <body>
 <div style="margin:auto;width:60%;">
  <p>
    Selenium示例
  </p>
  <?php
    if($_POST){
        $username = isset($_POST['username'])? trim($_POST['username']):'';
        $password = isset($_POST['password'])? trim($_POST['password']):'';
        if($username=='zaixian' && $password = '123456'){
            echo "<p>您好,{$username} !</p>";
        }
    }
    ?>
  <form id="loginForm" method="POST">
   <input name="username" type="text" class="form-control" id="username" placeholder="UserName"/>
   <input name="password" type="password" class="form-control" id="password" placeholder="Password"/>
   <button name="Login" type="submit" id="Login" class="btn" value="Login">Login</button>
  </form>
  </div>
 </body>
<html>

上一篇: Selenium IDE定位策略 下一篇: Selenium WebDriver简介