2017-10-10 5 views
0

Je suis en train de tester le Selenium sous Mac OS à l'aide du pilote Gecko. J'utilise Firefox 56.L'erreur 'échec de recherche d'informations d'adresse' s'affiche lors de l'exécution du test sélénium à l'aide du pilote Gecko sous Mac OS

Voici le code que j'ai utilisé pour initialiser le pilote Web.

System.setProperty("webdriver.gecko.driver", "/Users/<username>/Documents/Tools/geckodriver"); 
DesiredCapabilities capabilities=DesiredCapabilities.firefox();   
capabilities.setCapability("marionette", true); 
WebDriver driver = new FirefoxDriver(capabilities); 

Maintenant, quand j'exécute un test, il semble pilote Gecko est initialisé mais l'erreur mentionné ci-dessous est affiché et le navigateur n'est pas en cours d'initialisation.

1507662170977 geckodriver INFO geckodriver 0.19.0 
1507662170983 geckodriver INFO Listening on 127.0.0.1:42748 
FAILED CONFIGURATION: @BeforeClass initializeDriver 
org.openqa.selenium.WebDriverException: failed to lookup address information: nodename nor servname provided, or not known 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z' 
System info: host: '<username>s-MacBook-Pro.local', ip: '192.168.1.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144' 
Driver info: driver.version: FirefoxDriver 
remote stacktrace: stack backtrace: 
    0:  0x10d96ca8e - backtrace::backtrace::trace::h69682bcb53decaf6 
    1:  0x10d96cacc - backtrace::capture::Backtrace::new::hdc9d731a957304a6 
    2:  0x10d8ce8e3 - webdriver::error::WebDriverError::new::h4c6ae7c4aac049c6 
    3:  0x10d8cf352 - _$LT$webdriver..error..WebDriverError$u20$as$u20$core..convert..From$LT$std..io..error..Error$GT$$GT$::from::ha068e680ab4e1954 
    4:  0x10d8a221e - geckodriver::marionette::MarionetteHandler::create_connection::hc09196342b760e35 
    5:  0x10d8847d4 - _$LT$webdriver..server..Dispatcher$LT$T$C$$u20$U$GT$$GT$::run::hfda25a6dc0b512aa 
    6:  0x10d85c645 - std::sys_common::backtrace::__rust_begin_short_backtrace::h95009c1d3a320838 
    7:  0x10d86411d - std::panicking::try::do_call::h8c5f07f1fc714fb2 
    8:  0x10da1d9cc - __rust_maybe_catch_panic 
    9:  0x10d879f55 - _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::h6a96e09ff4d37bff 
    10:  0x10da19c3b - std::sys::imp::thread::Thread::new::thread_start::h823686b907c11c46 
    11:  0x7fffdf79f93a - _pthread_body 
    12:  0x7fffdf79f886 - _pthread_start 

Votre solution serait appréciée.

+0

Etait-ce travailler avant? La première chose que je vérifie avec des erreurs bizarres comme ceci est que le geckodriver que j'utilise est compatible avec la version de Firefox que j'ai. Je vérifie également que tout cela est compatible avec la version de sélénium que j'utilise. – mrfreester

+0

Il semble qu'il y ait un problème avec votre résolution DNS. Pourriez-vous définir vos journaux pour tracer et afficher à nouveau la sortie? –

+0

@mrfreester Non, je crée une infrastructure d'automatisation pour la première fois sur une machine Mac. –

Répondre

1

Apparemment, il y a un problème with the JDK and OSX où le nom d'hôte ne reconnaît pas localhost.

La solution est d'ajouter localhost/etc/hosts

0

Vous devez passer les capacités au conducteur:

WebDriver driver = new FirefoxDriver(capabilities); 
+0

Ouais, j'ai aussi essayé ça. Ne fonctionne toujours pas. –