Question: I have a date picker where I can select a date range like 3months, 7 days or this year.
How can I select "This year" from a drop down menu?

Here is the code:

```
 <div class="full">
   <div class="range-preset">
    <div class="date-range-selector">
    <label>Date Range:</label>
    <select class="full" style="width:230px; ">
    <option value="custom">Custom</option>
    <option value="yesterday">Yesterday</option>
    <option value="7days">7 Days</option>
    <option value="30days">30 Days</option>
    <option value="90days">90 Days</option>
    <option value="this_month">This Month</option>
    <option value="last_month">Last Month</option>
    <option value="two_months_ago">Two Months Ago</option>
    <option value="this_year">This Year</option>
    <option value="yesterday">Yesterday</option>
    </select>
   </div>
  </div>

```

I tried this:

```
driver.findElement(By.className("full.option.this_year")).click();

```

Any help please, thank you

Answer: 
No spring does not use cloning to create prototype scoped instances.

Below is the code snippet taken from AbstractBeanFactory.doGetBean() function:

```
// Create bean instance.
if (mbd.isSingleton()) {
    sharedInstance = getSingleton(beanName, new ObjectFactory<Object>() {
        @Override
        public Object getObject() throws BeansException {
            try {
                return createBean(beanName, mbd, args);
            }
            catch (BeansException ex) {
                // Explicitly remove instance from singleton cache: It might have been put there
                // eagerly by the creation process, to allow for circular reference resolution.
                // Also remove any beans that received a temporary reference to the bean.
                destroySingleton(beanName);
                throw ex;
            }
        }
    });
    bean = getObjectForBeanInstance(sharedInstance, name, beanName, mbd);
}

else if (mbd.isPrototype()) {
    // It's a prototype -> create a new instance.
    Object prototypeInstance = null;
    try {
        beforePrototypeCreation(beanName);
        prototypeInstance = createBean(beanName, mbd, args);
    }
    finally {
        afterPrototypeCreation(beanName);
    }
    bean = getObjectForBeanInstance(prototypeInstance, name, beanName, mbd);
}

```

The createBean method call boils down to below code:

```
BeanUtils.instantiateClass(constructorToUse);

```
No. Spring scopes such as **prototype** or **singletone** do not follow strictly design patterns. The naming of scopes was used to intuitively suggest behavior container provides.

This way you can have a "singleton" pattern within the container and create another object outside of the container. Similarly "prototype" pattern does not have to implement "clone" functionality.

You may want to look into this link as well:   
 [Singleton design pattern vs Singleton beans in Spring container](https://stackoverflow.com/questions/2637864/singleton-design-pattern-vs-singleton-beans-in-spring-container)

More elaborate explanations here:   

<https://springframework.guru/gang-of-four-design-patterns/prototype-pattern/>