package io.qameta.htmlelements.context;

import io.qameta.htmlelements.extension.ExtensionRegistry;
import org.openqa.selenium.WebDriver;

import java.util.Optional;

public class Context {

    private Context parent;

    private Store store;

    private ExtensionRegistry registry;

    private Context() {
        this.store = new DefaultStore();
    }

    public Optional<Context> getParent() {
        return Optional.ofNullable(parent);
    }

    private void setParent(Context parent) {
        this.parent = parent;
    }

    public Store getStore() {
        return store;
    }

    public ExtensionRegistry getRegistry() {
        return registry;
    }

    private void setRegistry(ExtensionRegistry registry) {
        this.registry = registry;
    }

    public Context newChildContext(Class<?> proxyClass) {
        Context childContext = new Context();
        childContext.setRegistry(ExtensionRegistry.create(proxyClass));
        childContext.setParent(this);
        return childContext;
    }

    public static Context newWebPageContext(Class<?> webPageClass, WebDriver driver) {
        Context context = new Context();
        context.setRegistry(ExtensionRegistry.create(webPageClass));
        context.getStore().put("driver", driver);
        return context;
    }


}

@@ -978,16 +978,179 @@
 (this);%0A
+        //extension%0A        getStore().get(%22driver%22, WebDriver.class).ifPresent(driver -%3E %7B%0A            childContext.getStore().put(%22driver%22, driver);%0A        %7D);%0A
         

Fix hover