0

Unable to compile code line "options.addarguments("--start-maximized") ", using selinum 3.0.1 and using ChromDriver_win32 latest version and eclispe Mars.. Let me know what i am missing. I am able to compile and run my test without options..

 import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.chrome.ChromeDriver;
 import org.openqa.selenium.chrome.ChromeOptions;
 import org.openqa.selenium.interactions.Actions;

 public class IRSLabTestCase {
    WebDriver driver1=  new ChromeDriver();
    ChromeOptions options = new ChromeOptions();
    options.addArguments("--start-maximized"); //--> this line not getting     compiled.
    driver1 = new ChromeDriver(options);'
}
m_callens
  • 6,100
  • 8
  • 32
  • 54

2 Answers2

1

It wont work because you can only initialize members in a class.
To do operations on them you have to put it in a function or do those in a constructor.

You are initializing driver1 object twice .You have to learn java basics.Else you can't proceed further.

You can do like below.

public class IRSLabTestCase {

    WebDriver driver1;
    ChromeOptions options = new ChromeOptions();      

    public IRSLabTestCase(){
         options.addArguments("--start-maximized"); 
         driver1 = new ChromeDriver(options);'
    }
}
Madhan
  • 5,750
  • 4
  • 28
  • 61
  • 1
    Your code does the job, but you've left your answer incomplete, and there's no need for "obviously". – Mark Lapierre Mar 15 '17 at 22:18
  • @MarkLapierre there is some connectivity issue which lead to that.Thanks I've edited. – Madhan Mar 16 '17 at 10:52
  • Thanks for the explanation. when i tried it worked right after i posted my initial message . I didn't understood the reason. Thanks again. driver1 is a copy paste issue. – seshaddri Nallabola Mar 22 '17 at 14:54
-1

Instead of chrome options you should try this:

ChromeDriver driver;  
driver=new ChromeDriver();
driver.manage().window().maximize();

or

           ChromeOptionsoptions =new  ChromeOptions();
            options.addArguments("--start-maximized");
            driver = new ChromeDriver(options);
Prashant Palve
  • 132
  • 2
  • 11