當我嘗試使用MVN測試命令行運行我的硒測試時出現此錯誤。奇怪的是,我嘗試了4天前,它成功運行:無法在45000毫秒內綁定到鎖定端口70 54
------------------------------------------------------
T E S T S
-------------------------------------------------------
Running GoogleNavigationTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 45.672 sec <<< FAILURE!
Results :
Failed tests: testApp(GoogleNavigationTest): Unable to bind to locking port 70
54 within 45000 ms
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
這裏是我的測試:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.Test;
public class GoogleNavigationTest {
@Test
public void testApp(){
// The Firefox driver supports javascript
FirefoxProfile firefoxProfile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver();
// Go to the Google Suggest home page
driver.get("http://www.google.com/webhp?complete=1&hl=en");
// Enter the query string "Cheese"
WebElement query = driver.findElement(By.name("q"));
query.sendKeys("Cheese");
// Sleep until the div we want is visible or 5 seconds is over
long end = System.currentTimeMillis() + 5000;
while (System.currentTimeMillis() < end) {
WebElement resultsDiv = driver.findElement(By.className("gssb_e"));
// If results have been returned, the results are displayed in a drop down.
if (resultsDiv.isDisplayed()) {
break;
}
}
// And now list the suggestions
List<WebElement> allSuggestions =
driver.findElements(By.xpath("//td[@class='gssb_a gbqfsf']"));
for (WebElement suggestion : allSuggestions) {
System.out.println(suggestion.getText());
}
}
}
Hv您驗證了端口7054上的sumtintin runnin。另外如果你不使用一些特定的firefoxprofile,那麼就不需要創建新的ff配置文件。 –
你有什麼版本的Firefox?你有什麼版本的Selenium? – Arran
我沒有創建任何Firefox的配置文件 – AmiraGL