內部文字是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=='yiibai' && $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>