Bị báo lỗi port 4444 is busy selenium năm 2024

On Oct 18, 2:38 pm, santhosh venkat <[email protected]> wrote: \> I am getting the following error \>

\> 15:06:16.492 WARN - Failed to start: [email protected]:4444

\> Exception in thread "main" java.net.BindException: Selenium is already \> running on port 4444. Or some other service is. \> at \> org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:399) \> at \> org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:234) \> at \> org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:198) \>

\> *I triedhttp://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer.

\> But still getting the same error.I am sure no other service is using

\> this port..*

\> \> How can i fix it ? I know if i reboot my machine it will work. However \> I want to know the proper solution for the same. \> \> Thanks in advance

Hi Santosh,

I faced simillar problem. What you could do is just kill the process running on port 4444

by command taskkill -f /processid

But make sure that it was started by your script only.

Regards, Prathamesh

Nội dung bài viết

Tham khảo cách setup môi trường Selenium Java trên hệ điều hành MAC/ Linux:

  • Cài đặt/ cấu hình Selenium Java và Eclipse (MAC OS)
  • Cài đặt/ cấu hình Selenium Java và Eclipse (Ubuntu Linux)
  • Recommend nên dùng Java version 1.8 hoặc 1.11
    • Download trên trang chủ: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    • Nếu các bạn ngại đăng kí tài khoản trên Oracle thì tải file cài đặt Offline: https://drive.google.com/drive/folders/1iCTMnWFQzMrMoN2ZSZxHl4dDuIhnqztO
    • Trong này mình đã để sẵn các file Offline: Java/ Eclipse/ Firefox/ Selenium/ Driver

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Sau khi tải về -> cài đặt bình thường -> click Next -> Install cho đến khi hoàn tất
  • Sau khi cài đặt xong bật command line (cmd) kiểm tra version đã cài đặt thành công
    • java -version

Bị báo lỗi port 4444 is busy selenium năm 2024

Cài đặt Eclipse IDE

  • Link download: https://www.eclipse.org/downloads/packages/release/, tùy vào hệ thống của bạn phiên bản 32/64 bit để lựa chọn cho phù hợp. Chọn bản Eclipse IDE for Java Developer là đáp ứng đủ cho nhu cầu công việc.

Bị báo lỗi port 4444 is busy selenium năm 2024

Tải về thư viện Selenium

  • Link download: http://selenium-release.storage.googleapis.com/index.html?path=2.53/
  • Chọn và tải: selenium-server-standalone-2.53.1.jar

Tạo dự án Java

  • Xả nén Elipse IDE > chạy eclipse.exe từ bước 2 đã tải về
  • Tạo 1 thư mục ngang hàng vs thư mục eclipse – đặt tên là my_work_space
  • Set workspace – mục đích để nếu cài đặt lại hệ thống thì eclipse sẽ tự load lại các dự án/tùy chọn bạn đã làm việc trước đó – ko cần phải cài đặt lại

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Tạo mới Project: File > New > Java Project > [Đặt tên Project] > Finish
    • Project name: Selenium Tutorials

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Tạo mới Package: Right click vào thư mục src > New > Package > [Đặt tên Package] >Finish
    • Package name: automationfc.com

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Tạo mới Class: Right click vào Package > New > Class > [Đặt tên Class] > Finish
    • Class name: Topic_01_Check_Environment

Bị báo lỗi port 4444 is busy selenium năm 2024

Thêm thư viện Selenium vào dự án

  • Tạo mới 1 thư mục trong project để lưu trữ các java library hoặc browser driver cần dùng
    • Đặt tên thư mục là lib

Bị báo lỗi port 4444 is busy selenium năm 2024

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Copy thư viện selenium-server-standalone-2.53.1.jar từ bước 03 ở trên dán vào thư mục lib

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Click chuột phải vào thư viện và Add vào Build Path

Bị báo lỗi port 4444 is busy selenium năm 2024

Cài đặt TestNG plugin vào Eclipse

  • Chọn Help > Install New Software

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Nhập:
    • Name = TestNG
    • Location = https://testng.org/testng-eclipse-update-site/6.14.3/
    • Click Add

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Click vào Select All và nhấn Next button

Bị báo lỗi port 4444 is busy selenium năm 2024

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Click “I accept the terms of the license agreement” và nhấn Finish button

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Nếu hiện ra 1 popup thông báo về Security Warning, nhấn OK để tiếp tục

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Hoàn thành, click Yes để khởi động lại Eclipse

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Sau khi khởi động xong, cần kiểm tra TestNG đã được cài đặt thành công: Window > Preferences
    • TestNG plugin đã được tích hợp vào Eclipse

Bị báo lỗi port 4444 is busy selenium năm 2024

Chạy thử Testcase

  • Copy và Paste toàn bộ vào Class <Topic_01_Check_Environment> đã tạo

Bị báo lỗi port 4444 is busy selenium năm 2024

package automationfc.com; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class Topic_01_Check_Environment { WebDriver driver; @BeforeClass public void beforeClass() {

  driver = new FirefoxDriver();  
  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);  
  driver.manage().window().maximize();  
  driver.get("http://demo.guru99.com/v4/");  
} @Test public void TC_01_ValidateCurrentUrl() {
  String loginPageUrl = driver.getCurrentUrl();  
  Assert.assertEquals(loginPageUrl, "http://demo.guru99.com/v4/");  
} @Test public void TC_02_ValidatePageTitle() {
  String loginPageTitle = driver.getTitle();  
  Assert.assertEquals(loginPageTitle, "Guru99 Bank Home Page");  
} @Test public void TC_03_LoginFormDisplayed() {
  Assert.assertTrue(driver.findElement(By.xpath("//form[@name='frmLogin']")).isDisplayed());  
} @AfterClass public void afterClass() {
  driver.quit();  
} }

Xử lí lỗi

  • Nếu gặp báo error thì import thư viện vào bằng cách hover vào hàm bị báo lỗi và import đúng thư viện cần thiết

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Run testcase
    • Click chuột phải vào Class test chọn Run As > TestNG Test

Bị báo lỗi port 4444 is busy selenium năm 2024

  • Kết quả sau khi run pass

Bị báo lỗi port 4444 is busy selenium năm 2024