1

I am beginning with selenium WebDriver, I want to make an independente copy of my WebDriver, I try to use the interface Cloneable but I could not because the class WebDriver doesn't implements the interface Cloneable.

I also try to create a class containing an attribute WebDriver like that

public class A implemnts Cloneable{
       private WebDriver driver;

       public A(WebDriver driver){
              this.driver = driver;
       }

       public WebDriver clone throws CloneNotSupportedException {
              A mClass = (A) super.clone();
              return mClass.driver;
       }
}

WebDriver driver = new A().clone();

but it does not work well ... Does anyone know how I can do this ???

Sam Dufel
  • 17,560
  • 3
  • 48
  • 51
M.SALHI
  • 74
  • 1
  • 5
  • Why do you want to make copy of webdriver? – kotoj Sep 13 '16 at 08:45
  • I have a lot of data in a table, and for each line it exist clickable link, I want to the principal driver continue its Work and in same time with another driver that contains all feature of the driver main (there are many JavaScript in this page so access to the currentUrl is not sufficient). The second driver is created to click on the link of each line. – M.SALHI Sep 13 '16 at 13:43
  • Why dont you open each link in a new window/tab – Madhan Sep 13 '16 at 18:15
  • new Tab doesn't work well with HtmlUnitDriver when I creat new Tab, every time the driver.getwindowhandles() == 1 – M.SALHI Sep 13 '16 at 20:00
  • But even the new tab work, I don't wont to use it, because when you switching to the new tab you bloc the access to the main tab by this driver. But for me I wont to use to driver in same time – M.SALHI Sep 13 '16 at 20:33

1 Answers1

1

You can find how to copy object here.

But I'm suggesting to use the same webdriver in another thread.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
ModX
  • 829
  • 7
  • 10