小编use*_*735的帖子

使用Selenium WebDriver的Spring Boot Web应用程序

我试图让我的头围绕春季启动,我有一些问题试图将selenium集成到我的春季启动应用程序中.我正在尝试实现一个简单的网页,它有一个输入框和按钮.输入框将包含一个URL,然后该按钮将启动导航到输入的URL的selenium浏览器.

我目前有一个简单的弹簧启动应用程序,包括以下内容:

的index.html

包含传递给myController的输入表单(用户在此处键入URL).

myController.java

@Controller
public class myController {

    @Autowired
    private WebDriver driver;

    ....
}   
Run Code Online (Sandbox Code Playgroud)

的pom.xml

含有硒..

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.4.0</version>
    </dependency>   
Run Code Online (Sandbox Code Playgroud)

我运行项目时的错误:

 APPLICATION FAILED TO START


 Description:

 Field driver in com.project.myController required a bean of type 'org.openqa.selenium.WebDriver' that could not be found.


 Action:

 Consider defining a bean of type 'org.openqa.selenium.WebDriver' in your configuration.
Run Code Online (Sandbox Code Playgroud)

我正在尝试创建Selenium WebDriver的实例,以便我可以在需要时使用它.我只会在这个控制器中需要它,所以我在这里宣布它.我错过了什么?任何帮助将不胜感激.先感谢您.

java selenium spring maven spring-boot

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

maven ×1

selenium ×1

spring ×1

spring-boot ×1