目录
一、影刀安装与环境配置
1. 安装影刀:影刀RPA - 影刀官网
2. 环境配置
2.1 登录已经获取的账号找到个人中心的自动化插件
2.2 打开chrome浏览器的扩展中心并将影刀插件开关打开
二、简单认识网页的构成
1. 以登录网页为例
2. 网页代码展示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
html {
height: 100%;
}
body {
height: 100%;
}
.container {
height: 100%;
background-image: linear-gradient(to right, #fbc2eb, #a6c1ee);
}
.login-wrapper {
background-color: #fff;
width: 358px;
height: 588px;
border-radius: 15px;
padding: 0 50px;
position: relative;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.header {
font-size: 38px;
font-weight: bold;
text-align: center;
line-height: 200px;
}
.input-item {
display: block;
width: 100%;
margin-bottom: 20px;
border: 0;
padding: 10px;
border-bottom: 1px solid rgb(128, 125, 125);
font-size: 15px;
outline: none;
}
.input-item:placeholder {
text-transform: uppercase;
}
.btn {
text-align: center;
padding: 10px;
width: 100%;
margin-top: 40px;
background-image: linear-gradient(to right, #a6c1ee, #fbc2eb);
color: #fff;
}
.msg {
text-align: center;
line-height: 88px;
}
a {
text-decoration-line: none;
color: #abc1ee;
}
</style>
</head>
<body>
<div class="container">
<div class="login-wrapper">
<div class="header">微信</div>
<div class="form-wrapper">
<!-- <div > -->
<input type="text" name="username" placeholder="用户名" class="input-item">
<input type="password" name="password" placeholder="用户密码" class="input-item">
<div class="btn">登录</div>
</div>
<div class="msg">
没有账户?
<a href="#">注册</a>
</div>
</div>
</div>
</body>
</html>
3. 网页定位元素时对属性及其它条件的简单理解
3.1 id属性:可以类比为人的身份证,具有唯一性
- 优点: 通常是唯一的,定位精准。
- 使用场景: 元素有唯一的ID属性时,首选使用ID进行定位。
3.2 class属性:就像衣服,用于装饰
- 优点: 适用于多个相同类型的元素。
- 缺点: 可能不唯一,需要结合其他属性使用。
- 使用场景: 元素没有唯一ID,但有类名且类名能准确区分目标元素,同时需配合其他条件一起使用。
3.3 index:就像书的页码,用于定位
3.4 innerText:就像书里的内容
3.5 type:类型,如文本输入框通常为text,按钮通常为button
3.6 xpath:可以把它看作是在文档中指定一个路径,告诉浏览器或程序去找到你想要的内容
- 优点: 可以精确定位元素,无需元素有特定的ID或类名。
- 缺点: 结构变化时容易失效,复杂的XPath表达式可能影响性能。
- 使用场景: 复杂页面结构中,其他属性不能唯一定位元素时使用。