JavaScript错误:"无法访问死对象

时间:2016-09-06 10:59:19

标签: javascript java selenium browser

我正在进行selenium自动化测试,同时测试eclipse以下错误。

    org.openqa.selenium.WebDriverException: [JavaScript Error: "can't access dead object" {file: "file:///tmp/anonymous7428125082578056129webdriver-profile/extensions/fxdriver@googlecode.com/components/synthetic-mouse.js" line: 8554}]'[JavaScript Error: "can't access dead object" {file: "file:///tmp/anonymous7428125082578056129webdriver-profile/extensions/fxdriver@googlecode.com/components/synthetic-mouse.js" line: 8554}]' when calling method: [wdIMouse::click]
    Command duration or timeout: 12 milliseconds
    Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
    System info: host: 'xxxxxxx', ip: '192.168.1.5', os.name: 'Linux', os.arch: 'amd64', os.version: '4.3.5-300.fc23.x86_64', java.version: '1.8.0_71'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=44.0.2, platform=LINUX, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
    Session ID: a201e42f-93d6-4286-8ebd-9ded33e8af5b

更新1:

此Code Open Two浏览器(firefox和chrome)用于我们网站的并行测试。

这是我的代码:

      try{  
      baseUrl = "http://www.xxxxyyyyy.net/";
      driver.get(baseUrl);
      driver.manage().window().maximize();
      driver1.get(baseUrl);
      driver1.manage().window().maximize();

      driver.findElement(By.linkText("Sign In")).click();
      driver1.findElement(By.linkText("Sign In")).click();

        driver.findElement(By.id("email")).clear();
        driver1.findElement(By.id("email")).clear();
        driver.findElement(By.id("email")).sendKeys("xxx@xxx.mobi");
        driver1.findElement(By.id("email")).sendKeys("yyy@yyy.mobi");
        driver.findElement(By.id("pass")).clear();
        driver1.findElement(By.id("pass")).clear();
        driver.findElement(By.id("pass")).sendKeys("xxxx");
        driver1.findElement(By.id("pass")).sendKeys("yyyy");
        driver.findElement(By.id("send2")).click();
        driver1.findElement(By.id("send2")).click();


        driver.findElement(By.xpath(".//*[@id='store.menu']/nav/ul/li[1]/a")).click();
        driver1.findElement(By.xpath(".//*[@id='store.menu']/nav/ul/li[1]/a")).click();

        Actions builder = new Actions(driver);
        Actions builder1 = new Actions(driver1);            
        builder.moveToElement(driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[1]"))).build().perform();
        builder.click();
        driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[1]/div/div/div[2]/div/div[1]/form/button")).click();

        builder1.moveToElement(driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[1]"))).build().perform();
        builder1.click();
        driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[1]/div/div/div[2]/div/div[1]/form/button")).click();

        builder.moveToElement(driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[2]"))).build().perform();
        builder.click();
        driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[2]/div/div/div[2]/div/div[1]/form/button")).click();

        builder1.moveToElement(driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[2]"))).build().perform();
        builder1.click();
        driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[2]/div/div/div[2]/div/div[1]/form/button")).click();


        builder.moveToElement(driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[3]"))).build().perform();
        builder.click();
        driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[3]/div/div/div[2]/div/div[1]/form/button")).click();

        builder1.moveToElement(driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[3]"))).build().perform();
        builder1.click();
        driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[3]/div/div/div[2]/div/div[1]/form/button")).click();



        builder.moveToElement(driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[4]"))).build().perform();
        builder.click();
        driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[4]/div/div/div[2]/div/div[1]/form/button")).click();

        builder1.moveToElement(driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[4]"))).build().perform();
        builder1.click();
        driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[4]/div/div/div[2]/div/div[1]/form/button")).click();



        builder.moveToElement(driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[9]"))).build().perform();
        builder.click();
        driver.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[9]/div/div/div[2]/div/div[1]/form/button")).click();

        builder1.moveToElement(driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[9]"))).build().perform();
        builder1.click();
        driver1.findElement(By.xpath(".//*[@id='maincontent']/div[4]/div[1]/div[6]/ol/li[9]/div/div/div[2]/div/div[1]/form/button")).click();

        driver.get(baseUrl + "checkout/cart");

        driver1.get(baseUrl + "checkout/cart");


         driver1.findElement(By.xpath(".//*[@id='cartmail']")).click();
        Thread.sleep(10000);


         driver.findElement(By.xpath(".//*[@id='cartmail']")).click();

         Thread.sleep(10000);



         builder.moveToElement(driver.findElement(By.xpath(".//*[@id='shopping-cart-table']/tbody[1]/tr[2]/td/div/a[3]"))).build().perform();
         builder.click();
         driver.findElement(By.xpath("html/body/div[1]/header/div[2]/div/ul/li[2]/span/button")).click();
         driver.findElement(By.xpath("html/body/div[1]/header/div[2]/div/ul/li[2]/div/ul/li[3]/a")).click();

         builder1.moveToElement(driver1.findElement(By.xpath(".//*[@id='shopping-cart-table']/tbody[1]/tr[2]/td/div/a[3]"))).build().perform();
         builder1.click(); 
         driver1.findElement(By.xpath("html/body/div[1]/header/div[2]/div/ul/li[2]/span/button")).click();
         driver1.findElement(By.xpath("html/body/div[1]/header/div[2]/div/ul/li[2]/div/ul/li[3]/a")).click();

  }catch(Exception e)
  {
      System.out.println(e);
  }

更新2:运行此代码

  driver1.findElement(By.xpath(".//*[@id='cartmail']")).click(); 

部分答案:

我删除了所有扩展程序(浏览器插件),修复了我的问题。我不知道这种方式只能解决这个问题。解释为什么会出现这个问题。

0 个答案:

没有答案