小编use*_*112的帖子

在Selenium WebDriver中实现InternetExplorerDriver期间发生NoSuchElementException

目前,我正在使用WebDriver来调用IE浏览器来运行测试.但是NoSuchElementException当我尝试运行下面的简单示例时,我收到了一个.

但是,如果我使用Chrome驱动程序或Firefox驱动程序,代码工作正常.任何想法或想法将不胜感激.

罐: selenium-server-standalone-2.5.0.jar

码:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public static void main(String[] args) throws InterruptedException {
  DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
  ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
  WebDriver driver = new InternetExplorerDriver(ieCapabilities);
  driver.get("www.google.com");
  driver.findElement(By.name("q"));
}
Run Code Online (Sandbox Code Playgroud)

错误信息:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with name == q (WARNING: The server did not provide any stacktrace information)
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.5.0', revision: '13516', time: '2011-08-23 18:29:57'
System info: os.name: …
Run Code Online (Sandbox Code Playgroud)

java internet-explorer selenium-webdriver

16
推荐指数
2
解决办法
5万
查看次数

UI 级别测试和 API 级别测试有什么区别?

我在面试一些公司时遇到了这个问题。我觉得我不太好回答这个问题。但是,根据我的理解:

UI 级别测试更多的是关于最终用户将看到的内容,并且更适合用于验收测试。

API 级别测试适用于性能测试,因为它更容易模拟多个用户同时访问资源。而且,更容易查看问题所在。

任何人都可以给我更多的细节吗?我们什么时候应该选择使用哪种类型的测试?非常感谢。

testing automated-tests

4
推荐指数
2
解决办法
4万
查看次数

同步的Getter和Setter

我正在研究Java并发.我有一个关于synchronized和锁定的问题.

对于任何可变数据,我们应该将访问数据的所有方法放在同一个锁中.

但是,同样的锁是什么意思?

例:

public class SynchronizedInteger{
    private int value;
    public synchronized int get(){return value;}
    public synchronized void set(int value){this.value=value;}
}
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是为什么这两种方法都在同一个锁中?我知道他们是,但我想知道为什么?并且,这是否意味着类中的所有同步方法都在同一个锁中?

编辑:

所以,如果我在课程中再添加一个方法:

public synchronized void printOneToHunder(){

for(int i=0;i<100;i++) System.out.println(i);
Run Code Online (Sandbox Code Playgroud)

}

synchronized

public synchronized void printOneToHunder(){

public class SynchronizedInteger{
    private int value1;
    private int value2;
    public synchronized int get1(){return value1;}
    public synchronized void set1(int value){this.value1=value1;}
    public synchronized int get2(){return value2;}
    public synchronized void set2(int value){this.value2=value2;}       
}
Run Code Online (Sandbox Code Playgroud)

}

这个方法也会被包含在与setter和getter相同的块中?那么,当有一个线程使用setter或getter时,其他线程无法运行此方法?

而且,如果我将课程改为以下内容怎么办:

public class SynchronizedInteger{
    private int value;
    public synchronized …
Run Code Online (Sandbox Code Playgroud)

java concurrency getter-setter

2
推荐指数
1
解决办法
864
查看次数