Does WebDriverWait return an element in Java?

I’ve been writing tests with Java, and I use WebDriverWait like this:

WebDriverWait wait = new WebDriverWait(webDriver, timeoutInSeconds);

And my question comes up because I start to write test with Python, I come across WebDriverWait with Python like this:

element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "myDynamicElement"))

That means, WebDriverWait in Python waits and also returns an element at the same time. Can WebDriverWait in Java do the same, return an element? If it can, I have never known.

One to Many KStream-KStream join

How to perform one to many join between two kafka KStream?
The code given below joins two Kafka KStream which in a one to one manner.
Can someone guide so as how to perform a one to many join between KStream?
The data which is received in the topic is of generics < String ,JsonNode >
The data which is getting written in topic is of the form
{“from order”:”test1:,”from orderitem”:”test2″}
{“from order”:”test1:,”from orderitem”:”test3″}

Is it possible to get the data in this format:
{“from order”:”test1,{“from orderitem”:”test2″},{“from orderitem”:”test3″}}

public class ConsumerThreadPool {

private static final String TOPIC = "jre1";
private static final String NEXTTOPIC ="Kafka";
private static final String FINALTOPIC="jvm1";
private static final Integer NUM_THREADS = 1;
final Serializer<JsonNode> jsonSerializer = new JsonSerializer();
final Deserializer<JsonNode> jsonDeserializer = new JsonDeserializer();

final Serde<JsonNode> jsonSerde = Serdes.serdeFrom(jsonSerializer, jsonDeserializer);
final Serde<String> stringSerde = Serdes.String();

int threadNumber = 0;
private ConsumerConfigFactory consumerConfigFactory;

private ConsumerConnector consumer;
private ExecutorService threadPool;

public ConsumerThreadPool() {
    threadPool = Executors.newFixedThreadPool(NUM_THREADS);

public void startConsuming() {
    ConsumerConfig consumerConfig = consumerConfigFactory.getConsumerConfig();
    consumer = createJavaConsumerConnector(consumerConfig);
    KStreamBuilder builder = new KStreamBuilder();
    /* KTable<String,JsonNode> message = builder.table(stringSerde,jsonSerde,TOPIC);

    KTable<String,JsonNode> orderstream = message

            .filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER")
    KTable<String,JsonNode> orderlist=message.filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER_ITEM"));,jsonSerde,FINALTOPIC); ,jsonSerde,FINALTOPIC);    */ 

    KStream<String,JsonNode> orderstream=streams.filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER"))

    KStream<String, JsonNode> orderlist=streams.filter((k,v)-> v.path("table").asText().equals("TEST.S_ORDER_ITEM"))

    KStream<String,JsonNode> nextstream =orderstream.join(orderlist,(new ValueJoiner<JsonNode,JsonNode,JsonNode>(){
        public JsonNode apply(JsonNode first,JsonNode second){
            ObjectNode jNode = JsonNodeFactory.instance.objectNode();
            return jNode.put("from order",first.get("op_type").textValue())
                    .put("from orderitem",second.get("op_type").textValue() );
    KafkaStreams stream=new KafkaStreams(builder, consumerConfigFactory.getConsumeConfig());

public void consume() {

    KafkaConsumer<String,String> consumer = new KafkaConsumer<>(consumerConfigFactory.createConsume());

    while (true) {
        ConsumerRecords<String, String> records = consumer.poll(100);
            System.out.println("ConsumerRecords object created: "+records);
            threadPool.submit(new MessageConsumer(records, threadNumber));




Why array = array1 equal to array1 = array?

I’m try to check if the passed array is sorted or not:

public static boolean isSorted(int[] list){
    boolean isSorted = true;
    int[] arr = list;

    for (int i = 0; i < list.length; i++) {
        if (arr[i] != list[i]){
            isSorted = false;

     return isSorted;

I passed the array list and make array arr equal to list, what happened is the array list became equal to array arr after sorting.

What is java rules for that? and what should i do to separate arr from list?

Best way of saving data of my app

Hi i’m writing ‘Flashcards’ app I want to have some default deck/s (written in some file) and i want to allow user to extend those decks and create new ones. What’s the best way in android to save such data. I thought of using File objects in onCreate method but in this case it would create new folder all the time I open activity and the data won’t be saved. I need something that will create a folder in user’s storage which won’t be deleted as long as app is still on their phone (would Shared Preferences do that job?

Unable to invoke command prompt from windows service

I have a scenario where I want to open the command prompt while execute the following method –

public static int executeScript(){
    String scriptPath = "C:\test"
    String command = "cmd /c start  "+scriptPath+"\backup.bat > "+scriptPath+"\Logs.txt";
    Process process = Runtime.getRuntime().exec(command);
    return process.waitFor();

User wants to see the command prompt when the testRun.bat executes. When we deploy the application from command prompt it is running as expected user see the command prompt of the backup script execution. But In the production environment the application runs as window service, In this case the command prompt is not visible.

How can I show the command prompt when application is running as window’s service?

thanks in advance.

“Better Code” + User Input

So I just created a little program, which prints out a Box of Stars after asking the User to input a specific height and width of the Box, for example:
height: 4; width: 5 would print out this

Here is my code

import java.util.*;
public class Stars {
    public static Scanner scan = new Scanner(;
    public static int height = scan.nextInt();
    public static Scanner scan2 = new Scanner(;
    public static int width = scan.nextInt();
    public static void main(String[] args) {
        drawBox(height, width);
    public static void drawBox(int height, int width) {
        drawStarsWithSpaces(height, width);
    public static void drawStars(int width) {
        for (int i = 0; i < width; i++) {
    public static void drawStarsWithSpaces(int height, int width) {
        for (int x = 0; x < height - 2; x++) {
            for (int i = 0; i < width - 2; i++) {
                System.out.print(" ");

My first Question now is, how do implement a Text saying “Height of the Box” and after that “Width of the Box” when I start the program, so the user knows what to input.

Next thing is that I heard, to not use global variables for some reason and that I should implement code only after the main method… but what would the code of the program with these requirements look like?

Volley Library BasicNetwork.performRequest: Unexpected response code 400

I’m trying to use Android Volley library for login, my web API it’s a C#, and I’m using token for the security, When I try to connect to web API I got this error

E/Volley: [3455] BasicNetwork.performRequest: Unexpected response code
400 for

But when I do Login using Postman all work fine, this is the code that I’m using for getting the login

JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, AppConfig.URL_TOKEN, (String)null,
            new Response.Listener<JSONObject>() {
                public void onResponse(JSONObject response) {
                    try {
                        Log.e("LoginActivity", response.getString("access_token"));
                        Log.e("LoginActivity", response.getString("token_type"));
                        Log.e("LoginActivity", response.getString("expires_in"));
                        Log.e("LoginActivity", response.getString("error"));

                    } catch (JSONException e) {
            }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {
            //      Log.e("LoginActivity", error.getMessage().toString());
            Log.e("LoginActivity", "Error");
    }) {
        protected Map<String, String> getParams() {
            Log.e("getparams", "Is called");
            Map<String, String> params = new HashMap<String, String>();
            params.put("username", "aespinoza");
            params.put("password", "1");
            params.put("grant_type", "password");
            return params;

        public Map<String, String> getHeaders() throws AuthFailureError {
            HashMap<String, String> headers = new HashMap<String, String>();
            headers.put("Content-Type", "application/x-www-form-urlencoded");
            return headers;

    int x = 3;// retry count
    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 48,
            x, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

Thanks for your help

Get Log4j2 log file location

How can I get the location of a log4j log file?
Log4j ver 2.3 Config:

    <RollingFile name="ROLLLOGAPPENDER" fileName="./log/${infoFile}.log" filePattern="./log/${infoFile}-%i.log" append="true">
        <PatternLayout pattern="%d %-5p [%c{1}] %m%n"/>
        <ThresholdFilter level="${stdLevel}" onMatch="ACCEPT" onMismatch="DENY"/>
            <SizeBasedTriggeringPolicy size="${sizeOfFile}" />
        <DefaultRolloverStrategy max="${filesCount}"/>
    <Async name="ASYNC-LOG">
        <AppenderRef ref="ROLLLOGAPPENDER"/>

But it doesn’t work:

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.RollingFileAppender;
import org.apache.logging.log4j.core.config.Configuration;

LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
RollingFileAppender techical = (RollingFileAppender) config.getAppender(FILE_APPENDER_NAME);


org.apache.logging.log4j.core.appender.AsyncAppender cannot be cast to org.apache.logging.log4j.core.appender.RollingFileAppender