【Selenium项目实战】项目环境搭建:安装JDK、mysql、Tomcat、jpress和测试系统

前言

一直想学习自动化测试,但是都没行动,业余时间学习零零碎碎并记录20210416。

【Selenium项目实战】

  1. 项目环境搭建:安装JDK、mysql、Tomcat、jpress和测试系统
  2. 需求分析和用例设计
  3. 项目架构设计
  4. 完成项目基本测试
  5. 解决验证码问题
  6. 完成项目测试用例

项目环境搭建

本项目是一个JAVA开源项目,需要搭建JAVA运行环境,另外项目用到了数据库,所以需要安装数据库

1、安装JDK(参考:CSDN

(1)安装jdk软件一般步骤:

  • 到Oracle官网下载JDK1.8安装包。
  • 打开获取到的安装包按步骤安装到系统上。
  • 配置系统的环境变量。
  • 验证JDK1.8是否安装成功。

但是!在官网下载速度偏慢!!

(2)小编这边给大家附上从官网下载好的jdk-8u211-macosx-x64.dmg,其下载地址如下:

链接: https://pan.baidu.com/s/1ShNdeqV0AXS9LKdOKysAvg  密码: qprj

安装包如下图所示:

(ps:名称为jdk-8u211-macosx-x64.dmg,表示这是java8版本号为211的JDK安装包。)

(3)下载完成后,我们可以开始安装啦

1、双击dmg安装包

点击JDK 8 Update 211.pkg,后面就是傻瓜式的安装了,一直按照系统提示安装就好了~

2、配置系统的环境变量

       上一步骤,实际上,我们只是把JDK1.8的文件复制到操作系统上。但是我们如果要在terminal终端(或者iTerm2)上使JAVA命令,还要让应用知道JDK1.8环境的存在,那我们还需要配置系统的环境变量。

首先找到JDK安装的主目录:
/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

3、打开终端

进入当前用户的home目录:

cd ~/

打开.bash_profile并编辑:

open .bash_profile

在文件的末尾加上,并保存:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home

4、验证JDK1.8是否安装成功

java -version

附上安装成功的截图:

2、安装Tomcat,小编以mac为例

(1)下载地址:官网地址http://tomcat.apache.org/

(2)解压,启动

将文件解压,可以改名成为Tomcat,进入到bin目录下

MacBook-Pro Library % cd apache-tomcat-8.5.37/bin

(3)开启

MacBook-Pro bin % ./startup.sh
Using CATALINA_BASE:   /Users/ff/Library/apache-tomcat-8.5.37
Using CATALINA_HOME:   /Users/ff/Library/apache-tomcat-8.5.37
Using CATALINA_TMPDIR: /Users/ff/Library/apache-tomcat-8.5.37/temp
Using JRE_HOME:        /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk的副本/Contents/Home
Using CLASSPATH:       /Users/ff/Library/apache-tomcat-8.5.37/bin/bootstrap.jar:/Users/zhengxiaofang/Library/apache-tomcat-8.5.37/bin/tomcat-juli.jar
Tomcat started.

(4)关闭

./shutdown.sh

(5)查看进程

MacBook-Pro bin % ps -ef|grep tomcat-
  501  9019     1   0 11:18上午 ttys000    0:03.24 /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk的副本/Contents/Home/bin/java -Djava.util.logging.config.file=/Users/ff/Library/apache-tomcat-8.5.37/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /Users/ff/Library/apache-tomcat-8.5.37/bin/bootstrap.jar:/Users/ff/Library/apache-tomcat-8.5.37/bin/tomcat-juli.jar -Dcatalina.base=/Users/ff/Library/apache-tomcat-8.5.37 -Dcatalina.home=/Users/ff/Library/apache-tomcat-8.5.37 -Djava.io.tmpdir=/Users/ff/Library/apache-tomcat-8.5.37/temp org.apache.catalina.startup.Bootstrap start
  501  9022  7540   0 11:18上午 ttys000    0:00.01 grep tomcat-
MacBook-Pro bin %

(6)测试。在浏览器中打开localhost:8080

3、安装Mysql

  • Linux centos7x64系统下安装mysql(在线/离线)参考:CSDN
  • MAC安装Mysql

一、下面以MAC为例

1、执行安装命令:brew install mysql。

ffdeMacBook-Pro /Library % brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/protobuf-3.12.4.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/a18a7e12c9effa966240e3123ccd6d222b3663ae0399e48d00cb6c61bdae63f4?response-content-disposition=attachment%3Bfilename%3D%22protobuf-3.12.4.catalina
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/mysql-8.0.21.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/169ba3fdb1a0e61c98c47d021fbc20a9bd5513ac455b68ed449ce6fe96dbfa93?response-content-disposition=attachment%3Bfilename%3D%22mysql-8.0.21.catalina.bo
######################################################################## 100.0%
==> Installing dependencies for mysql: protobuf
==> Installing mysql dependency: protobuf
==> Pouring protobuf-3.12.4.catalina.bottle.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/protobuf
==> Summary
🍺  /usr/local/Cellar/protobuf/3.12.4: 268 files, 19.8MB
==> Installing mysql
==> Pouring mysql-8.0.21.catalina.bottle.tar.gz
==> /usr/local/Cellar/mysql/8.0.21/bin/mysqld --initialize-insecure --user=zhengxiaofang --basedir=/usr/local/Cellar/mysql/8.0.21 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql/8.0.21: 290 files, 291.2MB
==> Caveats
==> protobuf
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/protobuf
==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

To have launchd start mysql now and restart at login:
  brew services start mysql
Or, if you don't want/need a background service you can just run:
  mysql.server start
ffdeMacBook-Pro /Library %

或者搜索一下mysql版本:brew search mysql,再安装mysql:brew install mysql@5.7

ffdeMBP LaunchAgents % brew search mysql
==> Formulae
automysqlbackup                mysql++                        mysql-client@5.7               mysql-connector-c++@1.1        mysql-search-replace           mysql@5.7
mysql                          mysql-client                   mysql-connector-c++            mysql-sandbox                  mysql@5.6                      mysqltuner
==> Casks
homebrew/cask/mysql-connector-python                          homebrew/cask/mysql-utilities                                 homebrew/cask/sqlpro-for-mysql
homebrew/cask/mysql-shell                                     homebrew/cask/navicat-for-mysql
ffdeMBP LaunchAgents % brew install mysql@5.7
==> Downloading https://homebrew.bintray.com/bottles/mysql%405.7-5.7.31.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/14ae8121e150830abdf81c06028a0aeeeae3051e5571a0f60fe54ba60fcc0586?response-content-disposition=attachment%3Bfilename%3D%22mysql%
######################################################################## 100.0%
==> Pouring mysql@5.7-5.7.31.catalina.bottle.tar.gz
==> /usr/local/Cellar/mysql@5.7/5.7.31/bin/mysqld --initialize-insecure --user=zhengxiaofang --basedir=/usr/local/Cellar/mysql@5.7/5.7.31 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

mysql@5.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH run:
  echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include"


To have launchd start mysql@5.7 now and restart at login:
  brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/mysql@5.7/bin/mysql.server start
==> Summary
🍺  /usr/local/Cellar/mysql@5.7/5.7.31: 319 files, 232.4MB
ffdeMBP LaunchAgents %

2、安装完后启动mysql:mysql.server start。重启 mysql:brew services restart mysql

ffdeMacBook-Pro /Library % mysql.server start
Starting MySQL
. SUCCESS!

3、执行安全设置:mysql_secure_installation,按照提示选择密码等级,并设置root密码

ffdeMacBook-Pro /Library % mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : 
Success.

All done!
ffdeMacBook-Pro /Library %

二、创建新的数据库、用户并授权

1、登录mysql,修改配置添加远程访问权限

mysql -u root -p

按提示输入root密码

ffdeMacBook-Pro /Library % mysql -u root -p
Enter password: 

修改配置添加远程访问权限:update user set host = '%' where user ='root';将localhost设置为通配符%。localhost设置了“%”后便可以允许远程访问。

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set host = '%' where user ='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql>

使配置生效
localhost修改完成后执行以下命令使配置立即生效。flush privileges;

然后在查看配置

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql>  select host from user where user='root';
+------+
| host |
+------+
| %    |
+------+
1 row in set (0.00 sec)

已成功修改,这个时候就可以连接了。

三、检查mysql服务状态

先退出mysql命令行,输入命令brew services

显示如下结果说明mysql服务是正常的

Name  Status  User          Plist
mysql started ff /Users/ff/Library/LaunchAgents/homebrew.mxcl.mysql.plist

四、Brew 卸载MySql

1.brew remove mysql

2.brew cleanup

3.sudo rm ~/Library/LaunchAgents/com.mysql.mysqld.plist

4.sudo rm -rf /usr/local/var/mysql
 

4、安装Jpress

(1)官网下载。或者百度云盘:链接: https://pan.baidu.com/s/15baelOHq5um7Q16bFpbbdg  密码: uj9h

(2)下载完放到tomcat路径下的webapps。可以直接启动,也可以压缩完丢进来。如果把本目录有其他的war压缩包全部删掉,否则tomcat启动会自动解压项目。

(3)然后再重启tomcat服务器。

(4)重启后输入地址:http://localhost:8080/jpress/install。进入到了jpress安装界面了

(5)进入数据库mysql -u root 或者mysql -uroot -p
创建一个专属的数据库名:create database zxftest;

然后输入这个库名以及用户名和密码
点击下一步

下一步

完成

点击完成后重启tomcat,即可登录jpress 用户名和密码:admin/admin(自己前面设置的)

后续就可以用selenium来编写对该项目进行测试了。

“永不放弃,总有希望在前面等待!”送给自己,也送给正在阅读文章的博友们~

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小慌慌

感谢博友的鼓励,快乐分享~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值