2
我使用Selenium and Sauce Labs進行測試。在Selenium和Sauce Labs中添加自定義標題?
是否有Selenium屬性來添加自定義標題或追加一個字符串到用戶代理(如「使用醬實驗室」)?
我想選擇性地不加載一些Selenium的內容,因爲它導致單元測試過於挑剔。我在頁面上有一些小部件,有時頁面沒有完成加載...所以我想選擇性地不顯示它們爲Selenium。
我使用Selenium and Sauce Labs進行測試。在Selenium和Sauce Labs中添加自定義標題?
是否有Selenium屬性來添加自定義標題或追加一個字符串到用戶代理(如「使用醬實驗室」)?
我想選擇性地不加載一些Selenium的內容,因爲它導致單元測試過於挑剔。我在頁面上有一些小部件,有時頁面沒有完成加載...所以我想選擇性地不顯示它們爲Selenium。
我不熟悉醬實驗室,但你肯定可以做到這一點在一些硒設置,通過改變general.useragent.override
,如下(可能是適應性強):
使用FirefoxDriver you can:
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("general.useragent.override", "some UA string");
WebDriver driver = new FirefoxDriver(profile);
與Cabybara you can:
Capybara.register_driver :iphone do |app|
require 'selenium/webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['general.useragent.override'] = "iPhone"
Capybara::Driver::Selenium.new(app, :profile => profile)
end