提交 51895434 authored 作者: 黄夏豪's avatar 黄夏豪

[会议室测试] 新增了 跳转到排座页面和跳转到管理页面的方法

上级 55fa477b
......@@ -43,6 +43,13 @@
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
</dependencies>
......
package com.example.seleniumtest;
import com.example.seleniumtest.conferenceRoomTest.ConferenceActive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = {"com.example.seleniumtest"})
public class SeleniumTestApplication {
@Autowired
ConferenceActive conferenceActive;
public static void main(String[] args) {
SpringApplication.run(SeleniumTestApplication.class, args);
}
}
package com.example.seleniumtest.conferenceRoomTest;
import lombok.Data;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Data
@Component
public class ConferenceActive {
@Value(value = "${conferenceRoomTest.url}")
private String baseUrl;
private WebDriver webDriver;
public void login(String username,String password){
//todo 这个系统暂时没有登录的功能
}
public void toRowSeat(){
webDriver.get(baseUrl);
WebElement rowSeatButton = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/form/div[3]/div/div/button[1]/span"));
rowSeatButton.click();
}
public void toManager(){
webDriver.get(baseUrl);
WebElement managerButton = webDriver.findElement(By.xpath("/html/body/div/div/div[2]/form/div[3]/div/div/button[2]/span"));
managerButton.click();
}
}
package com.example.seleniumtest.selenium;
import com.example.seleniumtest.selenium.enums.Browser;
import com.example.seleniumtest.selenium.util.WebDriverUtil;
import org.openqa.selenium.WebDriver;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SeleniumTestApplication {
public static void main(String[] args) {
// SpringApplication.run(SeleniumTestApplication.class, args);
WebDriver driver = WebDriverUtil.getWebDriver(Browser.FIREFOX, false);
driver.get("http://www.itest.info");
String title = driver.getTitle();
System.out.printf(title);
driver.close();
}
}
conferenceRoomTest.url=http://123.60.53.83:8080/confhd/
\ No newline at end of file
spring.profiles.active=dev
\ No newline at end of file
package com.example.seleniumtest;
import com.example.seleniumtest.conferenceRoomTest.ConferenceActive;
import com.example.seleniumtest.selenium.enums.Browser;
import com.example.seleniumtest.selenium.util.WebDriverUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
class SeleniumTestApplicationTests {
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {SeleniumTestApplication.class})
public class SeleniumTestApplicationTests {
@Autowired
ConferenceActive conferenceActive;
@Test
void contextLoads() {
public void test1() {
WebDriver driver = WebDriverUtil.getWebDriver(Browser.FIREFOX, false);
conferenceActive.setWebDriver(driver);
conferenceActive.toManager();
// driver.close();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论