VietTuts

Tự Học Lập Trình Online

  • Home
  • Java
  • Servlet
  • JSP
  • Struts2
  • Hibernate
  • Spring
  • MyBatis
  • Java WS
  • C
  • C++
  • Python
  • PHP
  • Eclipse
  • VBA
  • Web
    • JavaScript
    • JQUERY
    • JSON
    • AJAX
    • CSS
    • HTML
    • Node.js
    • Angular 7
  • SQL
    • MySQL
    • SQL Server
  • Misc
    • Phần mềm tiện ích
    • Cấu trúc dữ liệu và giải thuật
    • Học lập trình C#
    • Selenium Test

Học Selenium - Automation Test

Kiểm thử tự động là gì? Automation Testing Selenium là gì? Các lệnh trong Selenium IDE – “Selenese” Giới thiệu Selenium Webdriver Selenium WebDriver Locators – xác định vị trí phần tử HTML

Tương Tác Người Dùng

Tương tác người dùng Tương tác Text Box Tương tác Radio Button Tương tác Check Box Tương tác Drop Down Ví dụ kéo thả trong Selenium Thao tác bàn phím Thao tác chuột Chọn nhiều hạng mục Tìm tất cả Link

Selenium WebDriver Nâng Cao

Page Object Model (POM) Selenium WebDriver Page Factory trong Selenium WebDriver XPath trong Selenium WebDriver Inject JQuery trong Selenium WebDriver

Mouse actions trong Selenium


Thao tác với bàn phím trong Selenium
Chọn nhiều hạng mục trong Selenium

Dưới đây là một số hành động chính của chuột mà các lập trình viên sẽ gặp phải trong hầu hết các ứng dụng:

  • Click: Thực hiện nhấp chuột. Chúng tôi cũng có thể thực hiện một nhấp chuột dựa trên tọa độ.
  • contextClick: Thực hiện ngữ cảnh nhấp / nhấp chuột phải vào một phần tử hoặc dựa trên các tọa độ
  • doubleClick: Thực hiện nhấp đúp vào webelement hoặc dựa trên tọa độ. Nếu để trống, nó thực hiện nhấp đúp vào vị trí hiện tại.
  • moveToElement: Di chuyển chuột đến phần tử được chỉ định hoặc dựa trên tọa độ.

Dưới đây là cú pháp để gọi mouse actions trong Selenium bằng cách sử dụng Selenium WebDriver:

void click(WebElement onElement)
void contextClick(WebElement onElement)
void doubleClick(WebElement onElement)
void moveToElement(WebElement toElement)
void moveToElement(WebElement toElement, long xOffset, long yOffset)

Nội dung chính

  • Ví dụ

Ví dụ

Dưới đây là ví dụ gọi mouse actions trong Selenium, mở trang web viettuts.vn, di chuyển chuột đến menu 'web', click vào link 'JavaScript'.

package vn.viettuts.selenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class MouseDemo {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", 
                "D:\\SeleniumWebdriver\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();

        // Open website
        driver.get("");

        // Maximize the browser
        driver.manage().window().maximize();
        
        WebElement webMenu = driver.findElement(By.xpath(".//a[@href='/web']"));
        
        // move mouse to webMenu element
        Actions actions = new Actions(driver);
        actions.moveToElement(webMenu).perform();
    }
}

Kết quả:

Ví dụ Mouse actions trong Selenium
Thao tác với bàn phím trong Selenium
Chọn nhiều hạng mục trong Selenium

Recent Updates

Selenium Test là gì? - Kiểm thử tự độngCác lệnh trong Selenium IDE - “Selenese”Chọn nhiều hạng mục trong SeleniumGiới thiệu Selenium WebdriverInject JQuery trong Selenium WebDriverKéo và thả trong SeleniumMouse actions trong SeleniumPage Factory trong SeleniumPage Object Model (POM) trong SeleniumSelenium WebDriver - Tương tác CheckBoxSelenium WebDriver - Tương tác Drop DownSelenium WebDriver - Tương tác người dùng

VietTuts on facebook

Học Lập Trình Online Miễn Phí - VietTuts.Vn

Danh sách bài học

Học java
Học servlet
Học jsp
Học Hibernate
Học Struts2
Học Spring
Học SQL

Câu hỏi phỏng vấn

201 câu hỏi phỏng vấn java
25 câu hỏi phỏng vấn servlet
75 câu hỏi phỏng vấn jsp
52 câu hỏi phỏng vấn Hibernate
70 câu hỏi phỏng vấn Spring
57 câu hỏi phỏng vấn SQL

About VietTuts.Vn

Hệ thống bài học trên VietTuts.Vn bao gồm các bài lý thuyết và thực hành về các công nghệ java và công nghệ web. Các bài lý thuyết trên hệ thống VietTuts.Vn được tham khảo và tổng hợp từ các trang http://javatpoint.com, http://www.tutorialspoint.com, http://docs.oracle.com/en …

Scroll back to top

Copyright © 2016 VietTuts.Vn all rights reserved. | VietTuts.Vn team | Liên hệ | Chính sách - riêng tư | sitemap.html | sitemap_index.xml