內部文本是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簡介