selenium java传感器修改
来源:互联网 发布:中国知识分子知乎 编辑:程序博客网 时间:2024/05/18 02:07
用selenium编写自动化脚本部署完传感器,还需要修改其中传感器类型
package gcpi;import org.openqa.selenium.By;import org.openqa.selenium.JavascriptExecutor;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.support.ui.Select;public class ModifyGcpi2 {public static void main(String[] args) throws InterruptedException {WebDriver driver = new FirefoxDriver();driver.get("http://192.168.28.52:8100/GCPI/0-webapp/html/factory_config.html#/sensor");// logindriver.findElement(By.cssSelector(".container-section-inputOne.container-section-input."+ "ng-pristine.ng-untouched.ng-valid.ng-valid-maxlength")).clear();driver.findElement(By.cssSelector(".container-section-inputOne.container-section-input."+ "ng-pristine.ng-untouched.ng-valid.ng-valid-maxlength")).sendKeys("aa");driver.findElement(By.cssSelector(".container-section-inputTwo.container-section-input."+ "ng-pristine.ng-untouched.ng-valid")).clear();driver.findElement(By.cssSelector(".container-section-inputTwo.container-section-input."+ "ng-pristine.ng-untouched.ng-valid")).sendKeys("123456");driver.findElement(By.cssSelector(".container-section-inputThree")).click();Thread.sleep(3000);// 传感器配置driver.findElement(By.xpath(".//*[@id='sensorId']")).click();Thread.sleep(2000); driver.manage().window().maximize();Thread.sleep(2000);// 鼠标滚动到页面最底部JavascriptExecutor driver_js= (JavascriptExecutor) driver;driver_js.executeScript("window.scrollTo(0,document.body.scrollHeight)");// 设置每页查询8条//Thread.sleep(3000);driver.findElement(By.xpath("html/body/div[5]/div/div/div/div/div[2]/div/div[2]/span[7]/input")).sendKeys("8");//driver.findElement(By.cssSelector("#checkfenye_mySelect2")).sendKeys("8");Thread.sleep(5000);// 下一页//driver.findElement(By.xpath(".//*[@id='fixed_left_id']/div/div/div/div/div[2]/div/div[2]/span[4]")).click();//Thread.sleep(3000);// 设置从第3页开始driver.findElement(By.xpath("html/body/div[5]/div/div/div/div/div[2]/div/div[2]/span[6]/input")).sendKeys("3");Thread.sleep(5000);int j = 133;while(true){for(int i=1; i<=5; i++){String xpathString = ".//*[@id='dataTables-example']/tbody/tr[" + i + "]/td[19]/a/img";System.out.println(xpathString);Thread.sleep(4000);driver.findElement(By.xpath(xpathString)).click();//Thread.sleep(2000);WebElement input = driver.findElement(By.xpath("html/body/div[5]/div/common-sensoralter/div[1]/div/div/div[2]/div[2]/input"));Thread.sleep(2000);//WebElement input = driver.findElement(By.cssSelector(".form-control.ng-pristine.ng-untouched.ng-valid"));//WebElement input = driver.findElement(By.className("form-control ng-pristine ng-untouched ng-valid"));//Thread.sleep(2000);JavascriptExecutor js = (JavascriptExecutor) driver; String value = (String)js.executeScript("return arguments[0].value;",input); System.out.println(value);Select userSelect2=new Select(driver.findElement(By.xpath(".//*[@id='alterList_device_type_id']"))); Thread.sleep(2000);if(value.equals("冷风机运行")){//Select userSelect2=new Select(driver.findElement(By.xpath(".//*[@id='alterList_device_type_id']"))); userSelect2.selectByVisibleText("冷风机运行信号");System.out.println("=======冷风机运行=======");}else if (value.equals("新风机运行")) {userSelect2.selectByVisibleText("新风机运行信号");System.out.println("=======新风机运行=======");}else if (value.equals("加湿器1运行")) {userSelect2.selectByVisibleText("加湿器运行信号");System.out.println("=======加湿器1运行=======");}else if (value.equals("加湿器2运行")) {userSelect2.selectByVisibleText("加湿器运行信号");System.out.println("=======加湿器2运行=======");}else if (value.equals("机组状态")) {userSelect2.selectByVisibleText("机组状态");System.out.println("=======机组状态=======");}else if (value.equals("室内温度")) {userSelect2.selectByVisibleText("环境温度");System.out.println("=======环境温度=======");}else if (value.equals("室内温度")) {userSelect2.selectByVisibleText("环境湿度");System.out.println("=======环境湿度=======");}else if (value.equals("室内CO2")) {userSelect2.selectByVisibleText("环境CO2");System.out.println("=======环境CO2=======");}else {System.out.println("========error=====" + i + "=============");}if(value.equals("aaa")){//Select userSelect2=new Select(driver.findElement(By.xpath(".//*[@id='alterList_device_type_id']"))); userSelect2.selectByVisibleText("风机故障报警");}if(value.equals("bbb")){//Select userSelect2=new Select(driver.findElement(By.xpath(".//*[@id='alterList_device_type_id']"))); userSelect2.selectByVisibleText("风扇电机状态");}//点击确认修改Thread.sleep(3000);driver.findElement(By.xpath("html/body/div[5]/div/common-sensoralter/div[1]/div/div/div[9]/span[1]")).click();Thread.sleep(3000); driver.findElement(By.xpath("html/body/common-showalerttxtbox/div/div/div/ul[2]/li/span")).click();}// 下一页driver.findElement(By.xpath("html/body/div[5]/div/div/div/div/div[2]/div/div[2]/span[4]")).click();Thread.sleep(3000);System.out.println("=====第" + j + "页====");j++;}}}
阅读全文
0 0
- selenium java传感器修改
- 基于selenium Java实现传感器的批量配置
- Selenium java
- selenium java
- Selenium + java
- java+selenium
- java selenium (一) selenium 介绍
- java selenium (一) selenium 介绍
- java selenium (一) selenium 介绍
- 由传感器传入、树莓派修改MySQL数据
- java传感器应用之指南针
- 2.Selenium之Selenium+Java环境搭建
- [selenium] selenium+java+testNG 显示等待
- [selenium] selenium+java+TestNG 自定义显示等待
- java selenium (八) Selenium IDE 用法
- Java Selenium起步
- Java Selenium封装--RemoteWebDriver
- Java Selenium封装--RemoteWebElement
- 数据库SQL优化大总结之 百万级数据库优化方案
- Linux环境下安装及配置Nginx
- java设计模式总结四:原型模式
- Android画板开发(四) 添加背景和保存画板内容为图片
- 使用Maven整合ssm框架的时候报错:target\classes\META-INF\MANIFEST.MF (系统找不到指定的路径。)
- selenium java传感器修改
- Vue之动态路由、嵌套路由
- 使用TensorBoard
- hive启动警告:Establishing SSL connection without server's identity verification is not recommended
- TP-Link图像研发工程师秋招回忆
- Redis Cluster 介绍与使用
- Windows10下vs2017的OpenGL的配置
- Java 线程 6
- 梯度下降算法