🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Github 与 Selenium 集成:完整教程 > 原文: [https://www.guru99.com/selenium-github.html](https://www.guru99.com/selenium-github.html) ### 什么是 GitHub? Git Hub 是一个协作平台。 它建立在 git 之上。 它允许您保留项目的本地和远程副本。 您可以在团队成员中发布它的项目,因为他们可以使用它并从那里对其进行更新。 **将 Git Hub 用于硒的优势。** * 当多个人在同一个项目上工作时,他们可以更新项目详细信息并同时通知其他团队成员。 * Jenkins 可以帮助我们从远程存储库中定期构建项目,这可以帮助我们跟踪失败的构建。 在本教程中,您将学习 * [Selenium 和 github 集成的先决条件](#6) * [Git 二进制文件安装](#1) * [Jenkins Git 插件安装](#2) * [使用 GitHub 插件设置我们的 Eclipse](#3) * [在 Git](#4) 上构建存储库 * [在 Git Hub 中使用硒的测试示例。](#5) ### Selenium 和 github 集成的先决条件 在开始 selenium 和 git hub 集成之前,我们需要安装以下组件。 1. Jenkins 安装。 2. Maven 安装。 3. Tomcat 安装。 您可以在以下链接中找到此安装步骤: 1)Maven 和 Jenkins 安装指南( [https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html](/maven-jenkins-with-selenium-complete-tutorial.html) ) 2)Tomcat 安装指南( [https://www.guru99.com/apache.html](/apache.html) ) ![Upload Selenium Script to GitHub](https://img.kancloud.cn/72/83/7283b93b3b7ee5b7ac6d532a70550f08_600x371.png "Using Selenium with Github") ## Git 二进制文件安装 现在让我们开始安装“ Git Binaries”。 **步骤 1)**启动浏览器并导航到 URL- https://git-scm.com/ **步骤 2)**下载最新的稳定版本。 **步骤 3)**单击 Windows 的下载文件下载后,我们就可以开始安装了。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/b9/a4/b9a4040a7011db0824b0ee9ec8834bac_936x360.png "Using Selenium with Github") **步骤 4)**转到下载位置或图标并运行安装程序。 **步骤 5)**单击“欢迎”和“通用”许可证。 **步骤 6)**在 git 设置向导中单击“下一步”按钮 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/9a/64/9a64710cc3822dc0430f22b9b8d69a94_513x398.png "Using Selenium with Github") **步骤 7)**阅读 GNU 通用公共许可证,然后单击下一步 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/84/72/8472662189c49da40bc8397d28ffbfd5_513x398.png "Using Selenium with Github") 将会弹出另一个窗口, **步骤 8)**在此步骤中, 1. 选择要安装“ Git Binaries”的目录,然后 2. 点击下一个按钮 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/fc/e4/fce44ff4d48aba256b9a6b50c76d801a_513x398.png "Using Selenium with Github") **步骤 9)**选择要安装的组件,然后单击下一步 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/cb/ec/cbec0c371dd9c90653e9249a8bc2b9a3_513x398.png "Using Selenium with Github") **步骤 10)**如果要为 Git 创建开始菜单文件夹,请保留默认设置,然后单击下一步。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/5b/be/5bbe9b24096a3888ede5e8d4ecf09977_513x398.png "Using Selenium with Github") **步骤 11)**在此步骤中, 1. 从 Windows 命令提示符中选择 Use Git 从命令行运行 Git,然后 2. 点击下一步。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/4c/c9/4cc91123aa9f1748fbc5c0d142459808_513x398.png "Using Selenium with Github") 保留默认设置,然后单击下一步进行安装。 **步骤 12)**在此步骤中, 1. 选择 Use Open SSH。它将帮助我们从命令行执行命令,并设置环境路径。 2. 单击下一步按钮。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/e5/63/e5630fa41d6575f903bac39112ce8986_513x398.png "Using Selenium with Github") **步骤 13)**在此步骤中, 1. 选择“签出 Windows 样式,提交 Unix 样式的行尾”。(git hub 如何处理文本文件中的行尾)。 2. 单击下一步按钮。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/c0/4c/c04cac09eed1976e17c0ea4d40dad034_513x398.png "Using Selenium with Github") **步骤 14)**在此步骤中, 1. 选择 Use MinTTY 是 Git Bash 的 MSys2 的默认终端 2. 点击下一个按钮 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/01/b3/01b3302b759417c9317f3a5dc1d63342_513x398.png "Using Selenium with Github") ![Upload Selenium Script to GitHub](https://img.kancloud.cn/b6/4a/b64a414536e11b10ab55cb2719bf05f9_513x398.png "Using Selenium with Github") 成功安装 git 后,即可访问 git。 打开命令提示符,然后键入“ git”,然后单击“ Enter”。如果您看到以下屏幕,则表示已成功安装 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/d9/1e/d91e160fe6ecde7fb9605506e643dadf_597x621.png "Using Selenium with Github") ## Jenkins Git 插件安装 现在让我们开始安装 Jenkins Git 插件。 **步骤 1)**启动浏览器并导航到您的 Jenkins。 **步骤 2)**单击管理詹金斯。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/c2/74/c274df3bcda7c3bdeb9d76fa4ee40032_288x250.png "Using Selenium with Github") **步骤 3)**单击管理插件,它将打开另一个窗口 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/c7/15/c715a3cfb01536e85bcd252e7e23012e_751x58.png "Using Selenium with Github") **步骤 4)**单击可用 TAB ![Upload Selenium Script to GitHub](https://img.kancloud.cn/08/b0/08b0aa00b9e61012f343b579194bd98d_390x49.png "Using Selenium with Github") **步骤 5)**在此步骤中, 1. 选择 GitHub 插件,然后 2. 单击立即下载并在重启后安装按钮。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/b3/2f/b32f7594607daf6046eba734e1b6894b_855x251.png "Using Selenium with Github") 现在它将安装以下插件。 安装完成后。 通过调用“ shutdown.bat”文件重新启动 Tomcat 服务器 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/9a/b0/9ab02eb4615546b99f2c527e11e75467_537x488.png "Using Selenium with Github") 重新启动 tomcat 和 Jenkins 之后,我们可以看到插件已安装在“已安装” TAB 中。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/2f/0e/2f0e7933bb674e762cab5d6387443dfe_471x175.png "Using Selenium with Github") ## 使用 GitHub 插件设置我们的 Eclipse 现在,让我们安装 Eclipse 的 GitHub 插件。 EGit 插件位置[的 URI https://download.eclipse.org/egit/updates/](https://download.eclipse.org/egit/updates/) **步骤 1)**启动 Eclipse,然后 1. 点击帮助按钮,然后 2. 点击安装新软件 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/ef/15/ef1508a44433c791ff4c62b00fa32e6d_295x335.png "Using Selenium with Github") **步骤 2)**单击我们的安装新软件,将打开以下屏幕。 现在点击添加 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/5f/14/5f147c414259a718f3a35d117a4e9b7e_857x59.png "Using Selenium with Github") **步骤 3)**在此步骤中, 1. 输入名称“ EGIT”,然后 2. 输入位置 [https://download.eclipse.org/egit/updates/](https://download.eclipse.org/egit/updates/) ,然后 3. 单击确定。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/7f/bc/7fbce32a3e9087d71f7e0500c4bd08f4_368x190.png "Using Selenium with Github") **步骤 4)**然后单击全选,然后单击下一步 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/44/41/44414520f5e54ba89167dc8593b526a7_883x691.png "Using Selenium with Github") **步骤 5)**单击下一步,然后单击接受许可协议,然后完成安装。 然后重新开始蚀。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/6d/65/6d655863083d80ea7690e371e3e20fea_835x543.png "Using Selenium with Github") ## 在 Git 上构建存储库 **步骤 1)**导航至 Git Hub URI: [https://github.com/](https://github.com/) 注册 git hub **步骤 2)**成功注册后,请单击创建新存储库 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/6c/9e/6c9e1f053267b37b38fce7fd2f5178c9_330x194.png "Using Selenium with Github") **Step 3)** In this step, 1. 输入存储库的名称,然后 2. 点击创建存储库 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/34/a8/34a88fb4a6a587b7f0cbbb12bab673ad_749x496.png "Using Selenium with Github") ## 在 Git Hub 中使用硒的测试示例。 **步骤 1)**在完成新存储库后,启动 Eclipse 1. 点击文件 2. 然后点击新按钮,然后 3. 点击其他 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/1f/e5/1fe59637e7f8cdbdbeed9a4d926c0ffc_578x411.png "Using Selenium with Github") **步骤 2)**在此步骤中, 1. 选择“ Maven 项目”并浏览位置。 2. 点击下一步 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/35/5a/355a14a2e8f4c76d12bf2ae1b7ca4399_606x551.png "Using Selenium with Github") **Step 3)** In this step, 1. 选择项目名称和位置,然后 2. 点击下一步 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/35/5a/355a14a2e8f4c76d12bf2ae1b7ca4399_606x551.png "Using Selenium with Github") **步骤 4)**单击下一步 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/ae/2d/ae2ddb13319f387991c7067838337507_606x548.png "Using Selenium with Github") **Step 5)** In this step, 1. 输入组 ID 和 2. 工件 ID 和 3. 单击完成按钮。 [![Upload Selenium Script to GitHub](https://img.kancloud.cn/4b/9a/4b9aa740bbb3a04b8a75a412d78a0dd7_606x548.png "Using Selenium with Github") ](/images/cassandra/021216_0757_Seleniumwit30.png) 单击完成按钮后,将立即创建一个项目。 **步骤 6)** 现在让我们创建一个示例脚本 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/96/a7/96a70d812ac52add57ed6d063d9727a7_476x513.png "Using Selenium with Github") 让我们将代码/本地存储库推送到 Git Hub。 **步骤 7)**在此步骤中, 1. 打开 Eclipse,然后导航到项目 2. 右键单击该项目,然后选择“团队”,然后 3. 选择共享项目 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/78/a9/78a95ab72640945b464f92bb3efc4678_529x635.png "Using Selenium with Github") **步骤 8)**单击上方屏幕中的“共享项目”后,我们将获得另一个窗口 在这一步中 1. 选择本地存储库,然后 2. 单击完成。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/fb/fe/fbfe38bc7f90b9ac46226a15af02c4e1_645x422.png "Using Selenium with Github") 单击完成后,我们可以看到创建本地存储库的项目结构中的更改。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/c9/78/c978d13f6e01fd7e1557b2c9e1456846_249x180.png "Using Selenium with Github") 现在是时候将我们的代码推送到 Git Hub 仓库了 **步骤 9)**在此步骤中, 1. 右键单击项目和团队,然后 2. 点击提交 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/e8/95/e895f217c0b6ba906243329a036ca052_641x743.png "Using Selenium with Github") **步骤 10)**在此步骤中, 1. 输入提交消息,然后 2. 选择我们要发送到 Git Hub 存储库的文件 3. 点击提交并推送 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/07/3a/073af6de91637f2c9c92c28b49fcb83d_642x640.png "Using Selenium with Github") 完成后,您会看到项目中的图标正在更改,它表示我们已成功将代码推送并提交到 Git Hub ![Upload Selenium Script to GitHub](https://img.kancloud.cn/4d/9e/4d9e427c2e46a9237ab597bab6d8f8c2_281x181.png "Using Selenium with Github") 我们可以在存储库的 Git 中心中验证我们的项目已成功推入存储库 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/49/ba/49babce7df3fd11d2fe7804c97319d4f_998x197.png "Using Selenium with Github") 现在是时候从詹金斯的 Git Hub 执行我们的项目了 **步骤 11)**启动浏览器并打开您的 Jenkins。 **步骤 12)**单击新项目。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/f6/47/f647c807790fb28a37dae6f02f680ee6_291x227.png "Using Selenium with Github") **步骤 13)**在此步骤中, 1. 输入商品名称 2. 选择 Maven 项目 3. 点击确定按钮 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/12/93/1293eb889fc8f834da0b67bacf3a8f45_731x382.png "Using Selenium with Github") **步骤 14)**在这一步中,我们将在 Jenkins 中配置 Git Hub 1. 点击 Git 并 2. 输入存储库 URI 3. 单击添加存储库 如果 Git Hub 中有多个存储库,则需要添加存储库的名称 Refspec 字段。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/a4/b1/a4b1147bfb0c79d49573a8e8d9e41007_1178x345.png "Using Selenium with Github") 我们可以在 Git Hub 中获取 URI ![Upload Selenium Script to GitHub](https://img.kancloud.cn/25/71/257161db79d90d0e699c53376861e3bb_990x344.png "Using Selenium with Github") **步骤 15)**在此步骤中, 1. 在文本框中添加 pom.xml 文件位置,然后 2. 然后指定 Maven 的目标和选项 3. 选择有关如何运行测试的选项 4. 点击保存按钮。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/72/7f/727f7f30349b0ef923c495fa8eecdbf8_740x502.png "Using Selenium with Github") **步骤 16)**一旦我们单击“保存”,将出现以下屏幕, 现在我们可以构建我们的项目,点击构建。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/34/d2/34d294de13ba3a8f74678ee13c0f521d_238x262.png "Using Selenium with Github") **步骤 17)**将显示内部版本,单击内部版本号或内部日期。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/1f/1f/1f1f8d71583c46693c7433cd02ea6b6d_336x101.png "Using Selenium with Github") **步骤 18)**一旦我们单击下面的内部版本号,屏幕就会出现,在此步骤中我们可以看到控制台输出,请单击控制台输出。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/f9/82/f982f02353b5483a34ce13fbff593f15_268x293.png "Using Selenium with Github") 最后,我们可以验证我们的构建已成功完成/执行。 ![Upload Selenium Script to GitHub](https://img.kancloud.cn/41/50/4150cdf3c0eab640b2805968f4f0bd66_385x181.png "Using Selenium with Github") ***本文由 Chaitanya Pujari 提供***