selenium用户中心增删改查全部脚本

这篇博客展示了如何使用Selenium自动化执行用户管理的增删改查操作,包括初始化Firefox浏览器驱动,登录网页,切换到用户管理页面,进行添加、删除和编辑用户的步骤,并处理了弹窗提示。
摘要由CSDN通过智能技术生成

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值