I have the following HTML: My following code for clicking “Google Search” button is working well using Java in WebDriver. I want to use JavaScript with WebDriver to click the button. How can I do it? Answer Executing a click via JavaScript has some behaviors of which you should be aware. If for ex…
Tag: java
How to copy an entire content from a directory to another in Java?
This is what I have. It copies everything just fine. But among the contents there are some folders. The folders are copied but the folder’s contents are not. Answer Recursion. Here is a method the uses rescursion to delete a system of folders: Didn’t test the code, but it should work. Basically, i…
fixed point arithmetics in java with fast performance
I need to represent some numbers in Java with perfect precision and fixed number of decimal points after decimal point; after that decimal point, I don’t care. (More concretely – money and percentages.) I used Java’s own BigDecimal now, but I found out, that it’s really slow and it sta…
How to run TestNG from command line
How exactly do I run a .java TestNG project from a command line? I have read through the TestNG documentation, and tried the following to no avail: … with the following testng.xml file in my project: The error I get is this: Obviously, I am not referencing TestNG correctly in my command line. Does anyon…
VisualVM launcher error
I’m trying to use the Eclipse VisualVM launcher. It seems pretty nice, except that it seems to spawn an instance if VisualVM too late to do any profiling of my application. My application finishes execution before the profiler is even initialized; once it starts up, an error window pops up, saying: cann…
wsimport – Two declarations cause a collision, same line given
Trying to use wsimport to generate a client for a SOAP endpoint. The WSDL and all XSD files used are local copies. This is the command being executed: Which gives this error: Note the line number is the same for the reported collision. Here’s the schema: I’ve tried removing the type definition, bu…
Call java class method from jar (not main)
Is this possible to call a specific method (other than main) of a class in a jar file from command line? Answer If you are talking about running Java code from the command-line, then no. You can specify a class name, but not which method to call, that always has to be public static void main(String[] argv). W…
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an exception – java.sql.SQLException: Missing IN or OUT parameter at index:: 1 Why is this happening and how do I fix it ? My output is- The code is- EDIT – To correct the code, we use- //insert 1st row //insert 2nd row…
How to get the attribute value of an xml node using java
I have an xml which looks like this: Here I want to retrieve the value of “source type” where type is an attribute. I tried the following, which didn’t work: This also didn’t work: Answer Since your question is more generic so try to implement it with XML Parsers available in Java .If …
Save an integer in two digit format in a variable in Java
How can I store an integer in two digit format in Java? Like can I set and print it as 01? Also, not only printing, if I say int b=a;, b should also print its value as 01. Answer I think this is what you’re looking for: Or, more briefly: An int just stores a quantity, and 01 and 1