简体   繁体   English

使用Selenium WebDriver在Firefox中自动化Web应用程序时获取检查异常

[英]Getting checked exception while automating a web application in Firefox using selenium webdriver

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class shopComLogin {
   public static void main(String[] args) throws InterruptedException{
   //Launch a Firefox Browser
   WebDriver window=new FirefoxDriver();
   //Navigating to Shop.com
   try{
   window.get("http://www.shop.com/");
   Thread.sleep(4000);
   window.findElement((By.xpath(".//*[@id='global-redirects']/div[2]/a[1]/div[1]/div[1]"))).click();
   Thread.sleep(2000);
   WebElement wb=window.findElement(By.xpath(".//*[@id='super-header-menu']/div[1]/a"));
   wb.click();
   Thread.sleep(4000);
   String enteredEmailId="shantanunandann@gmail.com";
   window.findElement(By.xpath(".//*[@id='sign_in_email_textfield']")).sendKeys(enteredEmailId);
   window.findElement(By.xpath(".//*[@id='no_account_radio_button']")).click();
   window.findElement(By.xpath(".//*[@id='signin_button']")).click();
   Thread.sleep(2000);
   String actualEmailId=window.findElement(By.xpath(".//*[@id='sign_in_email_textfield']")).getText();
   if(enteredEmailId.equalsIgnoreCase(actualEmailId)){
       System.out.println("Same email id "+ actualEmailId);
      }//if closed
      else{
     System.out.println("Email id field value does't match");  
     window.close();
   }//else closed
  }//try close
   catch(InterruptedException interrupt){
       interrupt.printStackTrace();
  }//catch close
 }//main closed
}//class closed

Exception which i am getting for this program is-
 Exception in thread "main" org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
 Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
System info: host: 'omega-d52b83806', ip: '10.0.0.7', os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_45'
  Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:98)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:84)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:197)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:190)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
at shopComLogin.main(shopComLogin.java:7)

I run this program today. 我今天运行此程序。 For the first 2 execution i was getting the desired output excluding the if block. 对于前2次执行,我得到了所需的输出(不包括if块)。 On the 4th run the program starts giving me exception as mentioned in the code above. 在第4次运行时,程序开始为我提供上面代码中提到的异常。 Don't know why i am getting this and how to fix it. 不知道为什么我会得到这个以及如何解决它。

Secondly in my first 2 executions the code written inside the if block is not executing at all ie, i am not getting the desired output nor any exception or error. 其次,在我的前2次执行中,如果if块中编写的代码根本没有执行,即我没有得到所需的输出,也没有任何异常或错误。 Can anyone tell me why? 谁能告诉我为什么?

I read some where & it worked for me below thing. 我读了一些地方,它在下面对我有用。

Its because of the more than one javaw.exe is running in the background. 这是因为后台运行了多个javaw.exe。 Kill those processes and give a try. 终止这些进程并尝试。

https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskman_end_process.mspx?mfr=true https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/taskman_end_process.mspx?mfr=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Selenium WebDriver自动化Flipkart应用程序 - Automating Flipkart Application using selenium WebDriver 使用Selenium WebDriver启动Firefox时获取NotConnectedException - getting NotConnectedException while launching firefox using Selenium WebDriver Selenium webdriver java - 自动化 Dojo 下拉菜单 - 没有获得此类元素异常 - Selenium webdriver java - Automating Dojo Dropdown - Getting no such element exception Selenium WebDriver用于自动化ReactJs应用程序 - Selenium WebDriver for automating ReactJs application 使用Selenium自动化Trading Web应用程序 - Automating the Trading Web Application using Selenium 硒webdriver异常(在Firefox中) - selenium webdriver exception (in firefox) 浏览网页上的链接时在Firefox上获取WebDriver异常-Firefox Web浏览器 - Getting WebDriver Exception on firefox while going through links on a webpage - Firefox Web Browser 使用 Selenium WebDriver 的 Spring Boot Web 应用程序 - Spring Boot Web Application using Selenium WebDriver 在 Java 程序 (Firefox) 中使用 Selenium Webdriver 获取无法连接错误 - Getting cannot connect error using Selenium Webdriver in Java program (Firefox) 使用硒webdriver junit测试自动化saksfifthavenue.com时无法关闭弹出窗口 - unable to close popup window while automating saksfifthavenue.com using selenium webdriver junit test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM