package com.bw.model;
import java.util.List;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ByClassName;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.UnexpectedAlertBehaviour;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
public class UserManager {
WebDriver driver;
public static void main(String[] args) throws InterruptedException {
UserManager fr = new UserManager();
fr.initwebderiver();
}
//初始化驱动
public void initwebderiver() throws InterruptedException {
boolean flag=false;
int count=0;
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,UnexpectedAlertBehaviour.IGNORE);
System.setProperty("webdriver.firefox.bin", "C://Program Files (x86)//Mozilla Firefox//firefox.exe");
driver = new FirefoxDriver(dc);
//driver.get("http://123.56.92.221/mainsite/src/html/login/login.html");
//driver.get("http://10.100.3.2/mainsite/src/html/login/login.html");
driver.get("http://www.baiwang.com/mainsite/src/html/login/login.html");
//driver.get("http://10.100.3.2/output/output/sysmgmt/userMgmt");
driver.findElement(By.id("username")).sendKeys("cpy001");
driver.findElement(By.id("password")).sendKeys("a123456");
driver.findElement(By.id("login-btn")).click();
Thread.sleep(18000);
//tab页面切换
List<WebElement> list=driver.findElements(By.tagName("li"));
list.get(4).click();
Thread.sleep
selenium用户中心增删改查全部脚本
最新推荐文章于 2022-09-27 17:25:09 发布
这篇博客展示了如何使用Selenium自动化执行用户管理的增删改查操作,包括初始化Firefox浏览器驱动,登录网页,切换到用户管理页面,进行添加、删除和编辑用户的步骤,并处理了弹窗提示。
摘要由CSDN通过智能技术生成