How to use the gecko executable with Selenium

前端 未结 10 1453
滥情空心
滥情空心 2020-11-28 08:20

I\'m using Firefox 47.0 with Selenium 2.53. Recently they have been a bug between Selenium and Firefox which make code not working. One of the solution is to use the Marion

10条回答
  •  情歌与酒
    2020-11-28 09:06

    I create a simple Java application by archetype maven-archetype-quickstar, then revise pom.xml:

    
        4.0.0
        com.example
        bar
        0.0.1-SNAPSHOT
        bar
        bar
    
        
            
                junit
                junit
                4.12
            
            
                org.apache.maven.plugins
                maven-resources-plugin
                3.0.1
            
            
                org.seleniumhq.selenium
                selenium-java
                3.0.0-beta3
            
            
                org.seleniumhq.selenium
                selenium-server
                3.0.0-beta3
            
            
                org.seleniumhq.selenium
                selenium-api
                3.0.0-beta3
            
            
                org.seleniumhq.selenium
                selenium-firefox-driver
                3.0.0-beta3
            
        
        
            bar
        
    
    

    and

    package bar;
    
    import java.util.concurrent.TimeUnit;
    
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    
    public class AppTest {
    
        /**
         * Web driver.
         */
        private static WebDriver driver = null;
    
        /**
         * Entry point.
         * 
         * @param args
         * @throws InterruptedException
         */
        public static void main(String[] args) throws InterruptedException {
            // Download "geckodriver.exe" from https://github.com/mozilla/geckodriver/releases
            System.setProperty("webdriver.gecko.driver","F:\\geckodriver.exe");
            driver = new FirefoxDriver();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            driver.get("http://localhost:8080/foo/");
            String sTitle = driver.getTitle();
            System.out.println(sTitle);
        }
    
    }
    

    You also use on Mac OS X, Linux: https://github.com/mozilla/geckodriver/releases

    and

    // On Mac OS X.
    System.setProperty("webdriver.gecko.driver", "/Users/donhuvy/Downloads/geckodriver");
    

提交回复
热议问题