Test case mẫu trong Selenium

Hướng dẫn sử dụng và các lệnh của công cụ kiểm thử giao diện, chức năng Selenium.
Post Reply
tvn
Admin
Posts: 4900
Joined: Tue 10 Aug, 2010 10:11 am
Location: HCM
Contact:

Test case mẫu trong Selenium

Post by tvn »

Gửi các bạn một test case ngắn gọn trong Selenium

Code: Select all

package com.example.tests;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;

public class test case selenium extends SeleneseTestCase {
	@Before
	public void setUp() throws Exception {
		selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://mail.google.com/");
		selenium.start();
	}

	@Test
	public void testTest case selenium() throws Exception {
		selenium.open("/");
		selenium.click("id=link-signup");
		selenium.waitForPageToLoad("10000");
		selenium.click("id=submitbutton");
		selenium.click("id=TermsOfService");
		selenium.click("id=Personalization");
		selenium.click("id=submitbutton");
		selenium.waitForPageToLoad("10000");
		verifyTrue(selenium.isTextPresent("Bạn không được để trống trường này."));
	}

	@After
	public void tearDown() throws Exception {
		selenium.stop();
	}
}
You do not have the required permissions to view the files attached to this post.



kidflash
Hoc Tester
Posts: 6
Joined: Wed 15 Aug, 2012 9:17 am
Contact:

Re: Test case mẫu trong Selenium

Post by kidflash »

Mình muốn chạy trên IE thi làm thế nào! Mình đã thử như thế này nhưng không được! bạn coi giúp mình với nhé!

Code: Select all

selenium = new DefaultSelenium("localhost", 4444, "*iexplore C:\\Program Files\\Internet Explorer Collection\\IE700\\iexplore7.exe", "http://mail.google.com");
selenium.start();



tvn
Admin
Posts: 4900
Joined: Tue 10 Aug, 2010 10:11 am
Location: HCM
Contact:

Re: Test case mẫu trong Selenium

Post by tvn »

kidflash wrote:Mình muốn chạy trên IE thi làm thế nào! Mình đã thử như thế này nhưng không được! bạn coi giúp mình với nhé!

Code: Select all

selenium = new DefaultSelenium("localhost", 4444, "*iexplore C:\\Program Files\\Internet Explorer Collection\\IE700\\iexplore7.exe", "http://mail.google.com");
selenium.start();
Bạn sửa lại theo cú pháp của Selenium này nha

Code: Select all

selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://mail.google.com/");

Code: Select all

selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://mail.google.com");
selenium.start();
Không có câu "C:\\Program Files\\Internet Explorer Collection\\IE700\\iexplore7.exe"



kidflash
Hoc Tester
Posts: 6
Joined: Wed 15 Aug, 2012 9:17 am
Contact:

Re: Test case mẫu trong Selenium

Post by kidflash »

Mình làm theo no hiện thông báo: "do you want to running scripts on this page?". Mình da thu = cách khác là viết theo kiểu IEDriver, ko biet viet theo kiểu này có tốt không, nhưng nó không hiển thị được muti windown.



kidflash
Hoc Tester
Posts: 6
Joined: Wed 15 Aug, 2012 9:17 am
Contact:

Re: Test case mẫu trong Selenium

Post by kidflash »

Khi chạy trên IE no chay thế này nữa là sao ak! xem thêm ở cai hình đính kèm nha bạn!
You do not have the required permissions to view the files attached to this post.



tvn
Admin
Posts: 4900
Joined: Tue 10 Aug, 2010 10:11 am
Location: HCM
Contact:

Re: Test case mẫu trong Selenium

Post by tvn »

kidflash wrote:Mình làm theo no hiện thông báo: "do you want to running scripts on this page?". Mình da thu = cách khác là viết theo kiểu IEDriver, ko biet viet theo kiểu này có tốt không, nhưng nó không hiển thị được muti windown.
Muốn chạy multi windows thì bạn tham khảo Selenium Grid. mình cũng chưa tìm hiểu kỹ vấn đề này, bạn xem thêm ở đây nha.



Post Reply

Return to “Hướng Dẫn Sử Dụng Selenium”