首页 \ 问答 \ java.lang.NullPointerException webdriver(java.lang.NullPointerException webdriver)

java.lang.NullPointerException webdriver(java.lang.NullPointerException webdriver)

我是使用webdriver进行autoamted测试的新手。有人请检查我收到的原因

java.lang.NullPointerException
    at SuccessfullHoverTestCib.testSuccessfullHoverTestCib
    (SuccessfullHoverTestCib.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source).....

我正在运行以下代码:

public class SuccessfullHoverTestCib {
    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();

    @Before
    public void setUp() throws Exception {
        File pathToFirefoxBinary = new File("C:\\Documents and Settings\\chakarova\\Local Settings\\Application Data\\Mozilla Firefox\\firefox.exe");  
        FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
        WebDriver driver = new FirefoxDriver(firefoxbin,null); 
        baseUrl = "http://cibnew.sofia.ifao.net:7001/cib_web/web";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void testSuccessfullHoverTestCib() throws Exception {
        driver.get(baseUrl);
        driver.findElement(By.id("inputButton")).click();
        driver.findElement(By.linkText("Hotels")).click();
        driver.findElement(By.id("pageLink_57")).click();
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            fail(verificationErrorString);
        }
    }

当我指向错误跟踪时,它链接到Test method->driver.get(baseUrl); 我认为这个问题与firefox.exe路径的定义有关,但我不知道如何解决它。任何帮助将不胜感激。


I'm a newbie in the autoamted testing using webdriver.Would somebody please check why I'm receiving

java.lang.NullPointerException
    at SuccessfullHoverTestCib.testSuccessfullHoverTestCib
    (SuccessfullHoverTestCib.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source).....

I'm running the following code:

public class SuccessfullHoverTestCib {
    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();

    @Before
    public void setUp() throws Exception {
        File pathToFirefoxBinary = new File("C:\\Documents and Settings\\chakarova\\Local Settings\\Application Data\\Mozilla Firefox\\firefox.exe");  
        FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
        WebDriver driver = new FirefoxDriver(firefoxbin,null); 
        baseUrl = "http://cibnew.sofia.ifao.net:7001/cib_web/web";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void testSuccessfullHoverTestCib() throws Exception {
        driver.get(baseUrl);
        driver.findElement(By.id("inputButton")).click();
        driver.findElement(By.linkText("Hotels")).click();
        driver.findElement(By.id("pageLink_57")).click();
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            fail(verificationErrorString);
        }
    }

When I point to the error trace, it links to the Test method->driver.get(baseUrl); I think the problem is connected with the definition of the path to the firefox.exe,but I don't know how to fix it.Any help will be appreciated.


原文:https://stackoverflow.com/questions/12747658
更新时间:2022-02-24 14:02

最满意答案

fork()创建fork()函数调用的进程的确切副本。 这意味着,你有两个完全相同的进程,并且在程序中处于同一点。 如果我们通过fork2()函数,会发生以下情况。

过程A(原始过程):
L0(过程A分叉,创建过程B)
L1(过程A再次分叉,创建过程C)
再见! (过程A退出)

过程B:
L1(过程B叉,创建过程D)
再见! (过程B退出)

过程C:
再见! (过程C退出)

过程D:
再见! (过程D退出)

操作系统决定它在每个分支处继续执行哪个进程,以及在运行时是否在任何点切换到另一个进程,因此输出可以在进程分叉后的任意时刻交错。 例如,如果操作系统选择始终遵循新过程,直到函数结束,您将得到以下输出:

L0   (A)  
L1   (B)  
Bye! (D)  
Bye! (B)  
L1   (A)  
Bye! (C)  
Bye! (A)

fork() creates an exact duplicate of the process that made the fork() function call. This means, that you then have two processes that are exactly the same, and are at the same point in the program. If we step through the fork2() function, the following happens.

Process A (original process):
L0 (process A forks, creating process B)
L1 (process A forks again, creating process C)
Bye! (process A exits)

Process B:
L1 (process B forks, creating process D)
Bye! (process B exits)

Process C:
Bye! (process C exits)

Process D:
Bye! (process D exits)

It is up to the operating system as to which process it proceeds with at each fork, and also as to whether it switches to another process at any point during run-time, so the output can be interleaved at any point after a process forks. For example, if the OS chose to always follow the new process until the end of the function, you would get the following output:

L0   (A)  
L1   (B)  
Bye! (D)  
Bye! (B)  
L1   (A)  
Bye! (C)  
Bye! (A)

相关问答

更多
  • 实际上,你的等待电话有效。 它会检测第一个子进程的结束并在之后继续。 如果你连续两次调用wait(),你将得到正确的行为。 更新的测试代码: #include #include #include #include main() { pid_t pid; int status; switch(pid = fork()) { case -1: ...
  • 当你调用fork()最初只有你的VM被复制,并且所有的页面都被标记为copy-on write。 您的新子进程将拥有父进程虚拟机的逻辑副本,但在您真正开始写入之前,它不会消耗任何额外的RAM。 至于线程, fork在子进程中只创建一个类似于调用线程副本的新线程。 另外,只要您调用任何exec系列调用(我认为您希望),那么您的整个过程映像将被替换为新调用,并且只保留文件描述符。 如果你的父进程有很多打开的文件描述符,那么我建议你通过/proc/self/fd并关闭你不需要的子进程中的所有文件描述符。 When ...
  • 你需要把你的wait()调用放到一个循环中,如果它返回一个错误(-1),并且errno == EINTR继续循环。 任何其他错误都是一个真正的错误,应该这样对待。 像分析定时器这样的事情可能会导致信号被发送到进程,但是可能导致中断的信号是SIGCHLD ,正如您所知道的,当子进程更改状态时会调用它。 编辑:好的,我会在代码中写下答案: do { wpid = wait(&status); } while (wpid == -1 && errno == EINTR); if (wpid == -1) ...
  • 成功的fork在父级中返回两次 - 一次>0 pid,一次在子级中返回0 。 然后两者都从那一点继续前进。 就控制流而言,这就是它的全部内容。 如果您的代码是: int myfun() { if(fork()>0){ //Program code part 2 } return 0; } int main() { //Program code part 1 myfun(); //Program code part 3 return 0; ...
  • fork()创建fork()函数调用的进程的确切副本。 这意味着,你有两个完全相同的进程,并且在程序中处于同一点。 如果我们通过fork2()函数,会发生以下情况。 过程A(原始过程): L0(过程A分叉,创建过程B) L1(过程A再次分叉,创建过程C) 再见! (过程A退出) 过程B: L1(过程B叉,创建过程D) 再见! (过程B退出) 过程C: 再见! (过程C退出) 过程D: 再见! (过程D退出) 操作系统决定它在每个分支处继续执行哪个进程,以及在运行时是否在任何点切换到另一个进程,因此输出可以在 ...
  • 行为解释1: 程序通常无法控制输出顺序。 这是并行过程的要点。 操作系统决定在任何时间点执行哪个进程,并且两个进程同时执行(对人眼)。 因此,输出通常是互补的。 行为解释2: 你猜对了。 父流程在分叉之前完成。 如果您想要父pid,则可以在父进程中使用waitpid(x, &status, 0) ,如果您需要父进程保持活动直到执行子进程。 这个链接可以帮到你。 Explanation of Behaviour 1: The order of output cannot be controlled by th ...
  • posix.fork()是luaposix库的一部分,可以通过luarocks安装。 它的工作方式与fork(3)的工作方式大致相同; 它创建父进程的副本,并且在调用fork()之后它们都将执行所有内容。 fork()的返回值在子进程中为0,否则它是刚刚生成的子进程的PID。 这是一个人为的例子: local posix = require "posix" local pid = posix.fork() if pid == 0 then -- this is the child process ...
  • 如果通过.fork()生成一个新的V8进程,它将返回一个实现通信层的新child对象。 例如 var cp = require( 'child_process' ), proc = cp.fork( '/myfile.js' ); proc.on('message', function( msg ) { // continue whatever you want here }); 在/myfile.js您只需在完成工作后发送一个事件 process.send({ custom: ...
  • 适度可行的代码: #include #include #include static void printfXtimes(int a, int b) { for (int i = 0; i < b; i++) { printf("%i\n", a); usleep(10000); //sleep(1); } } int main(void) { for (int ...
  • 当fork()返回时,它会在两个进程(调用进程及其新的子进程)中返回(成功时)。 两者都以相同的代码(fork()之后的第一个命令)开始。 子进程获取当前状态的内存的精确副本。 因此,虽然所有变量现在都在其进程中具有自己的“化身”,但它们具有相同的值,就像在父进程中的fork()之前一样。 #include #include #include /* the type of array elements: */ typedef int Valu ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)