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 thefirefox.exe
,but I don't know how to fix it.Any help will be appreciated.
原文:https://stackoverflow.com/questions/12747658
最满意答案
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) ...
-
C进程:fork()作用域(C processes: fork() scope)[2023-01-11]
成功的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 ...
-
Lua fork并发进程(Lua fork concurrent processes)[2023-03-26]
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 ... -
是否可以派生子进程并等待它们在Node / JS中返回?(Is it possible to fork child processes and wait for them to return in Node/JS?)[2022-08-19]
如果通过.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 ...