Watir with webdriver, proxy, Firefox

前端 未结 3 849
小鲜肉
小鲜肉 2021-01-17 01:15

I am able to use watir-webdriver with IE, but I would prefer to use Firefox. Problem: I need a proxy. By googling around, I found some code snippets, but I am not able to pu

3条回答
  •  梦毁少年i
    2021-01-17 01:53

    The base problem in your original question is right in the error message

    webdrivertest.rb:3: syntax error, unexpected tCONSTANT, expecting keyword_do or '{' or '('
    

    The ruby interpreter is seeing something on the third line of your script that looks like a constant, in a place it's expecting something else.

    I suspect it's the start of the line where ruby expects a variable name, and you have a classname. Ruby expects variables named starting with an uppercase to be a constant. which is fine for defining a class, but not creating an instance of one, since the instance won't be a constant.

    It also looks like you are trying to do a new invocation using a 'new' keyword ala some other language, instead of using a .new method on whatever object you want to make a new one of, the ruby way.

    Compare the code in the answer by Mike where he does

    profile = Selenium::WebDriver::Firefox::Profile.new
    

    verses what you were trying to do on line 3

    FirefoxProfile profile = new FirefoxProfile();
    

    See how different they are? His is the way to do it.

提交回复
热议问题