Các liên kết của khách hàng Selenium
sẽ cố gắng xác định geckodriver
thực thi từ hệ thống PATH
. Bạn sẽ cần thêm thư mục chứa tệp thi hành vào đường dẫn hệ thống.
On Unix hệ thống bạn có thể làm như sau để thêm nó vào con đường tìm kiếm của hệ thống của bạn, nếu bạn đang sử dụng một vỏ bash tương thích:
export PATH=$PATH:/path/to/geckodriver
On của Windows bạn cần cập nhật biến Hệ thống đường dẫn để thêm đường dẫn thư mục đầy đủ vào tệp thực thi. Nguyên tắc cũng giống như trên Unix.
Tất cả dưới cấu hình cho ra mắt mới nhất firefox sử dụng bất kỳ ngôn ngữ lập trình ràng buộc được áp dụng cho Selenium2
để cho phép rối một cách rõ ràng. Với Selenium 3.0 và sau đó, bạn không cần phải làm bất cứ điều gì để sử dụng Marionette, vì nó được kích hoạt theo mặc định.
Để sử dụng Marionette trong các thử nghiệm của bạn, bạn sẽ cần phải cập nhật khả năng mong muốn của bạn để sử dụng nó.
Java:
Như ngoại lệ được rõ ràng nói rằng bạn cần phải tải về mới nhất geckodriver.exe
từ here và thiết lập tải geckodriver.exe
con đường mà nó tồn tại trong máy tính của bạn như sở hữu hệ thống với với biến webdriver.gecko.driver
trước khi bắt đầu điều khiển con rối và phóng firefox như sau: -
//if you didn't update the Path system variable to add the full directory path to the executable as above mentioned then doing this directly through code
System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");
//Now you can Initialize marionette driver to launch firefox
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new MarionetteDriver(capabilities);
Và đối với Selenium3
sử dụng như: -
WebDriver driver = new FirefoxDriver();
If you're still in trouble follow this link as well which would help you to solving your problem
NET:
var driver = new FirefoxDriver(new FirefoxOptions());
Python:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
# Tell the Python bindings to use Marionette.
# This will not be necessary in the future,
# when Selenium will auto-detect what remote end
# it is talking to.
caps["marionette"] = True
# Path to Firefox DevEdition or Nightly.
# Firefox 47 (stable) is currently not supported,
# and may give you a suboptimal experience.
#
# On Mac OS you must point to the binary executable
# inside the application package, such as
# /Applications/FirefoxNightly.app/Contents/MacOS/firefox-bin
caps["binary"] = "/usr/bin/firefox"
driver = webdriver.Firefox(capabilities=caps)
của Ruby:
# Selenium 3 uses Marionette by default when firefox is specified
# Set Marionette in Selenium 2 by directly passing marionette: true
# You might need to specify an alternate path for the desired version of Firefox
Selenium::WebDriver::Firefox::Binary.path = "/path/to/firefox"
driver = Selenium::WebDriver.for :firefox, marionette: true
JavaScript (Nút.js):
const webdriver = require('selenium-webdriver');
const Capabilities = require('selenium-webdriver/lib/capabilities').Capabilities;
var capabilities = Capabilities.firefox();
// Tell the Node.js bindings to use Marionette.
// This will not be necessary in the future,
// when Selenium will auto-detect what remote end
// it is talking to.
capabilities.set('marionette', true);
var driver = new webdriver.Builder().withCapabilities(capabilities).build();
Sử dụng RemoteWebDriver
Nếu bạn muốn sử dụng RemoteWebDriver
trong bất kỳ ngôn ngữ, điều này sẽ cho phép bạn sử dụng Marionette
trong Selenium
Grid.
Python:
caps = DesiredCapabilities.FIREFOX
# Tell the Python bindings to use Marionette.
# This will not be necessary in the future,
# when Selenium will auto-detect what remote end
# it is talking to.
caps["marionette"] = True
driver = webdriver.Firefox(capabilities=caps)
của Ruby:
# Selenium 3 uses Marionette by default when firefox is specified
# Set Marionette in Selenium 2 by using the Capabilities class
# You might need to specify an alternate path for the desired version of Firefox
caps = Selenium::WebDriver::Remote::Capabilities.firefox marionette: true, firefox_binary: "/path/to/firefox"
driver = Selenium::WebDriver.for :remote, desired_capabilities: caps
Java:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
// Tell the Java bindings to use Marionette.
// This will not be necessary in the future,
// when Selenium will auto-detect what remote end
// it is talking to.
capabilities.setCapability("marionette", true);
WebDriver driver = new RemoteWebDriver(capabilities);
NET
DesiredCapabilities capabilities = DesiredCapabilities.Firefox();
// Tell the .NET bindings to use Marionette.
// This will not be necessary in the future,
// when Selenium will auto-detect what remote end
// it is talking to.
capabilities.SetCapability("marionette", true);
var driver = new RemoteWebDriver(capabilities);
Lưu ý: Cũng giống như các trình điều khiển khác có sẵn để Selenium từ các nhà cung cấp trình duyệt khác, Mozilla đã phát hành bây giờ là một thực thi mà sẽ chạy cùng với trình duyệt. Theo dõi this để biết thêm chi tiết.
You can download latest geckodriver executable to support latest firefox from here
Tôi nghĩ đây không phải là vấn đề trùng lặp, nó xảy ra với' selenium 3' và đó là một vấn đề mới, stacktrace cũng khác. :) –
Bạn cần geckodriver để chạy thử nghiệm selenium 3 trong Firefox –