java+selenium+new——模拟鼠标悬浮操作——action类

package rjcs;

import java.util.*;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;

public class xinkaishi
{

    public static void main(String[] args)

    {
         System.setProperty("webdriver.firefox.bin","C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");    //设置火狐的安装路径,防止系统找不到

         FirefoxDriver driver = new FirefoxDriver();        //初始化FireFox浏览器实例,并打开浏览器

        try
        {
             driver.manage().window().maximize();         //最大化窗口

             Thread.sleep(5000);    

             driver.navigate().to("http://www.baidu.com"); 

             Thread.sleep(5000);

             Actions action = new Actions(driver);

             action.moveToElement(driver.findElementByLinkText("设置")).perform();     //鼠标悬浮在 设置  元素上面

             driver.findElementByClassName("setpref").click();      // 打开搜索设置

             Thread.sleep(10000);

        }catch (Exception e)
        {
            e.printStackTrace();
        }finally
        {
            driver.quit();

         }
    }

}

原文地址:https://www.cnblogs.com/xiaobaibailongma/p/12285951.html

时间: 2024-08-12 02:33:21

java+selenium+new——模拟鼠标悬浮操作——action类的相关文章

java+selenium+new——模拟鼠标右键操作——action类

package rjcs; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; public class a { public static voi

selenium webdriver模拟鼠标键盘操作

在测试使用Selenium webdriver测试WEB系统的时候,用到了模拟鼠标.键盘的一些输入操作. 1.鼠标的左键点击.双击.拖拽.右键点击等: 2.键盘的回车.回退.空格.ctrl.alt.shift等: 在webdriver中,有专门的一个类,是用来进行鼠标.键盘的模拟操作的,那就是Actions类,该类使用时,又会涉及到Keyboard.Mouse.CompositeAction(复合动作),先对Mouse的方法做简单罗列,然后再用代码说明: 1.鼠标左键点击: Actions ac

webdriver模拟鼠标悬浮

未经作者允许,禁止转载! 有时候会遇到这样的情况,鼠标停留在某一区域,不需要点击,悬浮在这一区域的上方就会显示该区域的下拉框,如下图 下面将鼠标停留在"日历"和"星座"这两个部分之间来回悬浮,下面是代码: package test20161207; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; im

Selenium之当鼠标悬浮时隐藏的元素才出现

在自动化过程中,有些导航按钮只有当鼠标悬浮在登录信息上时,它才能出现.这时候如果想要点击导航按钮直接用selenium的webDriver是无法定位的元素的,因为这些元素是隐藏的,只有鼠标悬浮时才出现,所以要记录一下,给大家一个参考 Actions action = new Actions(driver);                 WebElement nav=driver.findElement(By.xpath("/html/body/div[1]/div/div[1]/div[2]

python模拟鼠标键盘操作 GhostMouse tinytask 调用外部脚本或程序 autopy右键另存为

1.参考 autopy (实践见最后一章节) 用Python制作游戏外挂(上) AutoPy Introduction and Tutorial autopy.mouse.smooth_move(1, 1) 可以实现平滑移动 autopy - API Reference pip install PyUserInput SavinaRoja/PyUserInput [python3.5][PyUserInput]模拟鼠标和键盘模拟 Python-模拟鼠标键盘动作 autoit selenium借助

模拟鼠标键盘操作,含硬件模拟技术[转载]

键盘是我们使用计算机的一个很重要的输入设备了,即使在鼠标大行其道的今天,很多程序依然离不开键盘来操作.但是有时候,一些重复性的,很繁琐的键盘操作总会让人疲惫,于是就有了用程序来代替人们按键的方法,这样可以把很多重复性的键盘操作交给程序来模拟,省了很多精力,按键精灵就是这样的一个软件.那么我们怎样才能用VB来写一个程序,达到与按键精灵类似的功能呢?那就让我们来先了解一下windows中响应键盘事件的机制.    当用户按下键盘上的一个键时,键盘内的芯片会检测到这个动作,并把这个信号传送到计算机.如

pyautogui模拟鼠标键盘操作

安装pyautogui库 快捷键win+R调出"运行"命令窗口,输出cmd 在cmd命令窗口输出: pip install pyautogui 等待安装,直到完成 如何使用 打开python的IDLE 导入库: import pyautogui as pg 按需输入命令即可 命令 每条指令运行间隔(类似全局): pg.PAUSE=1 %每隔1s运行一条程序 鼠标类命令 获取当前鼠标位置: pg.position() 模拟鼠标左键: pg.click(x,y) 模拟鼠标双击左键: pg.

java+selenium+new——模拟键盘操作——复制、粘贴——action类

package rjcs; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.interactions.Actions; public class a { public static voi

java+selenium元素定位和元素操作

1.元素定位 ID定位元素: findElement(By.id("")); 通过元素的名称定位元素: findElement(By.name("")); 通过元素的html中的位置定位元素: findElement(By.xpath("")); 通过元素的标签名称定位元素: findElement(By.tagName("")); 通过元素的链接名称定位元素: findElement(By.linkText("&q