I have wrote a Java Class which uses selenium webdriver to quickly pass through a website and test various functions. I have also wrote a seperate class which will be used to execute the takeScreenshot() method. Once the test hits the code which executes the screenshot method, the browser closes and the J-Unit test fails and points to the line where I am calling the takeScreenshot() method. It is a null pointer exception but I cant figure out whats going wrong.. I have read through many articles and cant find an answer. I have read all of the posts on here which identify how to take a screenshot using selenium... The code is below:  **** Screenshot Class ****   public class Screenshot {   private WebDriver webDriver; File source;  public void takeScreenshot() {      try {         source = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);         FileUtils.copyFile(source, new File ("/Users/joshuadunn/Desktop/claimsScreenShot.png"));         System.out.println("Screenshot Taken!!!!");      } catch (IOException e) {         e.printStackTrace();     }  }  }   I then create a Screenshot Object and execute its takeScreenshot() method as follows:  @Test public void testClaimsTestToCalcNode() throws Exception {     driver.get(baseUrl + "/");     driver.findElement(By.id("becsStartCalculator")).click();     driver.findElement(By.id("MARITAL_STATUS_false")).click();     driver.findElement(By.id("btn_next")).click();     driver.findElement(By.id("HOME_ABROAD_false")).click();      *** This is where the null pointer is ***     *******************************     screenshot.takeScreenshot();     *******************************       driver.findElement(By.id("btn_next")).click();     driver.findElement(By.id("DETAILS_STUDENT_YOU_false")).click();   I hope you understand my problem!  EDIT **** - This is not a duplicate.. I am totally aware of what a null pointer is and how it can be fixed. Obviously something in my code is coming through as null, but I dont know what... The screenshot below is the only error i get (stacktrace)
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
I'm colorizing the header of a table formatted with column -ts $'\t'  Works well without color codes, but when I add color codes to the first line column doesn't properly align the output.  Without colored output it works as expected: printf "1\t2\t3\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n" | column -ts $'\t'  But when adding color on the first line column doesn't align the text of the colored row: printf "\e[7m1\t2\t3\e[0m\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n" | column -ts $'\t'  Observed this behaviour both on Ubuntu Linux and Mac OS X. How to "pretty" format JSON output in Ruby on Rails I would like my JSON output in Ruby on Rails to be "pretty" or nicely formatted.   Right now, I call to_json and my JSON is all on one line.  At times this can be difficult to see if there is a problem in the JSON output stream.  Is there way to configure to make my JSON "pretty" or nicely formatted in Rails? How do I "replay" the "Caveats" section from a homebrew recipe How do I list the members of a group? How can I see all the members of a group in Linux? Suppose $X,Y$ and $Z$ are multivariate normal with means and full covariance matrix. The conditional expectation $E(X | Y)$ is well know. What is the conditional expectation of $E(X | Y,Z)$ if $Y$ and $Z$ (and $X$) are correlated? Standard textbooks only seem to cover the case when $Y$ and $Z$ are uncorrelated. What command should I use to rotate wood to S,N,W,E,D and U?  I read the entire world edit guide and tried some things but all the results are not satisfactory. Delete the entire table rendered from different pages using Javascript How do I install the Firefox Developer Edition? Windows Update Slow on Vista Update I was able to get Readiness Tool to run but not the update Now the reediness tool will not even run Security Essentials will run    I have legal Windows 7 to install Do you think that is safe bet to try?    Had some performance issue so I ran MalwareBytes and Security Essentials.     It found some malware that was successfully removed.    I was able to Update Security Essentials and I ran it again for safety and it found nothing additions.     The last successful Windows Update was 5 days ago     Checking for Updates has been running 6 hours CPU 100%  network 0%     Windows6.0-KB947821-v35-x86.mnu fails to install It is supposed to be a tool to address update problems   I fear the registry got hacked to prevent updates     What can I do?  I know Vista.  I got it free. A cardinal $\kappa$ such that $2^{\lambda}<\kappa$ for all $\lambda<\kappa$ is regular? A cardinal $\kappa$ such that $2^{\lambda}&lt;\kappa$ for all $\lambda&lt;\kappa$ is regular?  I would appreciate very much an answer Custom Tools not Saving in Toolbar on Startup/ Normal.mxt? I am trying to save some tools that I have created into the default toolbar layout that is present when ArcMap 10.1 is launched.  It is possible to change the arrangement of toolbars, add new ones and even add in existing tools, but any custom tools I set in the commands category "geoprocessing tools" are gone and do not appear in the toolbar. How can I save these custom tools to the default layout that appears on startup?  Update:  Saving a document with the custom tools added and reopening it preserves the tools, but opening a template (10.1 mxd) containing the tools, then opening and older document will cause the tools to disappear. Oddly enough, any other changes made after the custom tools were added are preseved.  Update (03/18/2014):  I have upgraded to 10.2 and this has still not been fixed. I did not see this issue in the 10.21 changelog so I doubt it will address it. For those interested in this issue, I have started a forum post on the ESRI forums . I have been working on this exercise for a while now. It's in B.L. van der Waerden's Algebra (Volume I), page $19$. The exercise is as follows:     The order of the symmetric group $S_n$ is $n!=\prod_{1}^{n}\nu$. (Mathematical induction on $n$.)   I don't comprehend how we can logically use induction here. It seems that the first step would be proving $S_1$ has $1!=1$ elements. This is simply justified: There is only one permutation of $1$, the permutation of $1$ to itself.  The next step would be assuming that $S_n$ has order $n!$. Now here is where I get stuck. How do I use this to show that $S_{n+1}$ has order $(n+1)!$?  Here is my attempt: I am thinking this is because all $n!$ permutations of $S_n$ now have a new element to permutate. For example, if we take one single permutation $$ p(1,\dots,n) = \begin{pmatrix} 1 &amp; 2 &amp; 3 &amp; \dots &amp; n\\ 1 &amp; 2 &amp; 3 &amp; \dots &amp; n \end{pmatrix} $$ We now have $n$ modifications of this single permutation by adding the symbol $(n+1)$:  \begin{align} p(1,2,\dots,n,(n+1))&amp;= \begin{pmatrix} 1 &amp; 2 &amp; \dots &amp; n &amp; (n+1)\\ 1 &amp; 2 &amp; \dots &amp; n &amp; (n+1) \end{pmatrix}\\ p(2,1,\dots,n,(n+1))&amp;= \begin{pmatrix} 1 &amp; 2 &amp; \dots &amp; n &amp; (n+1)\\ 2 &amp; 1 &amp; \dots &amp; n &amp; (n+1) \end{pmatrix}\\ \vdots\\ p(n,2,\dots,1,(n+1))&amp;= \begin{pmatrix} 1 &amp; 2 &amp; \dots &amp; n &amp; (n+1)\\ n &amp; 2 &amp; \dots &amp; 1 &amp; (n+1) \end{pmatrix}\\ p((n+1),2,\dots,n,1)&amp;= \begin{pmatrix} 1 &amp; 2 &amp; \dots &amp; n &amp; (n+1)\\ (n+1) &amp; 2 &amp; \dots &amp; n &amp; 1 \end{pmatrix} \end{align}  There are actually $(n+1)$ permutations of that specific form, but we take $p(1,\dots,n)=p(1,\dots,n,(n+1))$ in order to illustrate and prove our original statement. We can make this general equality for all $n!$ permutations: $p(x_1,x_2,\dots,x_n)=p(x_1,x_2,\dots,x_n,x_{n+1})$ where $x_i$ is any symbol of our finite set of $n$ symbols and $x_{n+1}$ is strictly defined as the symbol $(n+1)$.  We can repeat this process for all $n!$ permutations in $S_n$. This gives us $n!n$ permutations. Then, adding in the original $n!$ permutations, we have $n!n+n!=(n+1)n!=(n+1)!$. Consequently, $S_n$ has order $n!$.  How is my reasoning here? Furthermore, is there a more elegant argument? I do not really see my argument here as incorrect, it just seems to lack elegance. My reasoning may well be very incorrect, however. If so, please point it out to me. Sentence vs proposition Uses of the 3D Cursor I know the 3D Cursor can be used to position new objects, or snap existing ones to a certain location - but what else can it be used for?  An exhaustive list of every possible use would be great (without repeating similar things like "pivot for spin tool", "pivot for screw tool" - which could simply be said as "Pivot for modeling tools"). Preventing other users from viewing my files Ref:   My Ubuntu user account name "user-3121" with type as "Administrator". There is one more account named "admin" with type as "Administrator". How can I be sure whether or not "admin" can login as me or otherwise view my files in "user-3121"?  I discussed this with the other user and we have tried to modify /etc/sudoers to protect my files:  Cmnd_Alias   SHELLS = /bin/sh,/bin/bash,/bin/ksh, /usr/bin/x11/passwd  Cmnd_Alias   SU = /usr/bin/su,/bin/su,/usr/bin/gksudo,/usr/bin/sudo,/usr/bin/su bash,/usr/bin/sudo /bin/bash,/usr/sbin/visudo  Cmnd_Alias   PASS = /usr/bin/passwd root,/bin/* * root,/bin/* * sysadmin,/bin/* * /home/sysadmin,/usr/bin/passwd  Cmnd_Alias      EDIT= /bin/* /etc/sudoers,/bin/* sudoers,/bin/* /etc/passwd,/bin/* passwd,/bin/* /etc/group,/bin/* group,/bin/* /etc/shadow,/bin/* shadow,/*/*/[a-z]* /etc/sudoers,/*/*/[a-z]* /etc/passwd,/*/*/[a-z]* /etc/group,/*/*/[a-z]* /etc/shadow,/*/*/[a-z]* sudoers,/*/*/[a-z]* passwd,/*/*/[a-z]* group,/*/*/[a-z]* shadow  Cmnd_Alias   CMDS = /usr/sbin/userdel * sysadmin,/usr/sbin/userdel sysadmin,/usr/sbin/deluser * sysadmin,/usr/sbin/deluser sysadmin  root    ALL=(ALL) ALL, !CMDS  %admin ALL=(ALL) ALL, !SHELLS, !SU, !CMDS, !PASS, !EDIT %sudo  ALL=(ALL) ALL,!SHELLS, !SU, !CMDS, !PASS, !EDIT  admin ALL=(ALL) ALL administrator ALL=(ALL) ALL   If "admin" can still read my data, how do I prevent that?  Also how does this configuration work, it allows "user-3121" to run some sudo commands, but it doesn't actually mention "user-3121" anywhere?  P.S. I'm the only person who knows the password for the "root" user, so that I can log in as root using the "su" command. I've tried everything I can think of. Resetting the router, changing the channel number and band.   The internet connection is fine, and then just hangs for a minute or 2, then returns to normal.   The wifi icon remains connected, and I have the latest 10.10.4 update installed. At first I thought it was a DNS bug with Yosemite, and have played with the settings such as changing DNS provider, changing the IPV6 to IPV4 only etc.  Driving me nuts. Has anyone had a similar problem? I've checked the surroundings with wifi scanners and have chosen the best channel available.     One thing I have noticed, it seems a lot more reliable on 5GHz as opposed to 2.4Ghz It seems to affect my Macbook Pro Retina 13in Early 2015 a lot more than the other devices on the network. I'm using a Virginmedia  1. I just came onto a project with a pretty huge code base.   I'm mostly dealing with C++ and a lot of the code they write uses double negation for their boolean logic.    if (!!variable &amp;&amp; (!!api.lookup("some-string"))) {        do_some_stuff();  }                                      I know these guys are intelligent programmers, it's obvious they aren't doing this by accident.   I'm no seasoned C++ expert, my only guess at why they are doing this is that they want to make absolutely positive that the value being evaluated is the actual boolean representation. So they negate it, then negate that again to get it back to its actual boolean value.   Is this correct, or am I missing something? What is the secret of making a really juicy burger? As the title says; What is the secret of making a really juicy burger? How do I remove all specific characters at the end of a string in PHP? Set origin to vertex in edit mode? I want to make the origin in edit mode at a vertex, but it keeps setting it to the last clicked-on face :( So now in edit mode the pivot is on the last clicked-on face ;(