不使用 setCapabilities 获取弃用警告 class
Getting Warning for deprecation without using setCapabilities class
我正在创建一个 Selenium 测试框架。我已经创建了我的 baseclass 并且现在正在添加东西。它处于基本阶段,但在执行测试时已经 class 我收到警告说我不遵循 W3C 语法。我已尝试 google 错误并了解我没有遵循它的地方,但我发现的文章仅提及已弃用的 setCapabilites。我做错了什么?
控制台日志文本:
ChromeDriver was started successfully.
May 29, 2022 2:21:12 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected upstream dialect: W3C
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found exact CDP implementation for version 101
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
我的基地class:
package resources;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class base {
public WebDriver driver;
public Properties prop;
public WebDriver initializeDriver() throws IOException {
FileInputStream fis=new FileInputStream("D:\Projects\EclipseWorkspace\E2EPrj\src\main\java\resources\data.properties");
prop = new Properties();
prop.load(fis);
String browserName = prop.getProperty("browser");
if(browserName.equals("chrome"))
{
//execute in chromedriver
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
System.setProperty("webdriver.chrome.driver","D:\Projects\chromedriver.exe");
driver = new ChromeDriver(options);
}
else if(browserName.equals("firefox"))
{
//execute in geckodriver
System.setProperty("webdriver.chrome.driver","D:\Projects\geckodriver.exe");
driver = new FirefoxDriver();
}
else if(browserName.equals("IE"))
{
//execute in IEdriver
System.setProperty("webdriver.chrome.driver","D:\Projects\IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));
// driver.manage().deleteAllCookies();
return driver;
}
// public String getScreenShotPath(String testCaseName, WebDriver driver) throws IOException
// {
// TakesScreenshot ts=(TakesScreenshot) driver;
// File source = ts.getScreenshotAs(OutputType.FILE);
// String destinationFile = ".\reports\"+testCaseName+".png";
// FileUtils.copyFile(source, new File(destinationFile));
// return destinationFile;
// }
}
这看起来是最新的 Selenium 版本 (4.2.0) 的问题,
因为它 在使用非 W3C 上限时记录警告 (release notes)
并报告为 Selenium Github Repo ISSUE 10711.
上的错误
据diemol(SeleniumHQ核心成员)评论,补丁即将发布
事实上,问题出在(Chrome、Edge 和 Gecko)驱动程序方面
when a session is created, driver's is returning non-W3C WebDriver caps
现在无需担心此警告,新的 Selenium 版本将忽略 ChromeDriver、EdgeWebDriver 和 GeckoDriver 的此警告,如您所见 commit on Selenium repo,直到此问题从WebDrivers 端。
我正在创建一个 Selenium 测试框架。我已经创建了我的 baseclass 并且现在正在添加东西。它处于基本阶段,但在执行测试时已经 class 我收到警告说我不遵循 W3C 语法。我已尝试 google 错误并了解我没有遵循它的地方,但我发现的文章仅提及已弃用的 setCapabilites。我做错了什么?
控制台日志文本:
ChromeDriver was started successfully.
May 29, 2022 2:21:12 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected upstream dialect: W3C
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found exact CDP implementation for version 101
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "chrome" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "javascriptEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "networkConnectionEnabled" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
May 29, 2022 2:21:12 P.M. org.openqa.selenium.W3CCapabilityKeysValidator validateCapability
WARNING: Support for Legacy Capabilities is deprecated; You are sending "platform" which is an invalid capability. Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/
我的基地class:
package resources;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class base {
public WebDriver driver;
public Properties prop;
public WebDriver initializeDriver() throws IOException {
FileInputStream fis=new FileInputStream("D:\Projects\EclipseWorkspace\E2EPrj\src\main\java\resources\data.properties");
prop = new Properties();
prop.load(fis);
String browserName = prop.getProperty("browser");
if(browserName.equals("chrome"))
{
//execute in chromedriver
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
System.setProperty("webdriver.chrome.driver","D:\Projects\chromedriver.exe");
driver = new ChromeDriver(options);
}
else if(browserName.equals("firefox"))
{
//execute in geckodriver
System.setProperty("webdriver.chrome.driver","D:\Projects\geckodriver.exe");
driver = new FirefoxDriver();
}
else if(browserName.equals("IE"))
{
//execute in IEdriver
System.setProperty("webdriver.chrome.driver","D:\Projects\IEDriverServer.exe");
driver = new InternetExplorerDriver();
}
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(3));
// driver.manage().deleteAllCookies();
return driver;
}
// public String getScreenShotPath(String testCaseName, WebDriver driver) throws IOException
// {
// TakesScreenshot ts=(TakesScreenshot) driver;
// File source = ts.getScreenshotAs(OutputType.FILE);
// String destinationFile = ".\reports\"+testCaseName+".png";
// FileUtils.copyFile(source, new File(destinationFile));
// return destinationFile;
// }
}
这看起来是最新的 Selenium 版本 (4.2.0) 的问题, 因为它 在使用非 W3C 上限时记录警告 (release notes)
并报告为 Selenium Github Repo ISSUE 10711.
上的错误据diemol(SeleniumHQ核心成员)评论,补丁即将发布
事实上,问题出在(Chrome、Edge 和 Gecko)驱动程序方面
when a session is created, driver's is returning non-W3C WebDriver caps
现在无需担心此警告,新的 Selenium 版本将忽略 ChromeDriver、EdgeWebDriver 和 GeckoDriver 的此警告,如您所见 commit on Selenium repo,直到此问题从WebDrivers 端。