无法识别并单击按钮

时间:2019-10-31 01:46:38

标签: java selenium-webdriver browserstack

我正在Windows 10计算机上的Selenium Web driver + TestNG + Java上运行Browserstack浏览器兼容性测试。

WebDriver driverSafari;

以下是我想要的功能:

   DesiredCapabilities caps = new DesiredCapabilities();
   caps.setCapability("browser", "Safari");
   caps.setCapability("browser_version", "11.0");
   caps.setCapability("os", "OS X");
   caps.setCapability("os_version", "High Sierra");
   caps.setCapability("browserstack.local", "false");
   caps.setCapability("browserstack.selenium_version", "3.5.2");
   caps.setCapability("resolution", "1024x768");
   driverSafari = new RemoteWebDriver(new URL(URL), caps);
   driverSafari.get("https://testsite.com/");
   WebElement element = driverSafari.findElement(By.name("password"));
    element.sendKeys("somepassword");
    element.sendKeys(Keys.ENTER);
    driverSafari.manage().window().maximize();
    driverSafari.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);    
    driverSafari.findElement(By.cssSelector("a[href*='findAClass']")).click();
   WebElement element2 = driverSafari.findElement(By.xpath("// [contains(text(),'Filters')]"));
  element2.click();

在此行WebElement element2..上引发错误。我可以在url的Safari浏览器中看到测试Browserstack正在加载,但是无法单击Filters按钮

An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_212'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {applicationCacheEnabled: true, browserName: safari, cleanSession: true, cssSelectorsEnabled: true, databaseEnabled: true, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: false, nativeEvents: true, platform: MAC, platformName: MAC, rotatable: false, version: 13605.3.8, webStorageEnabled: true}

*** Element info: {Using=css selector, value=span[@title='Filters']}

0 个答案:

没有答案