小编Ali*_*ott的帖子

使用watir-webdriver自动化时如何处理tinyMCE?

我正在评估Watir-webdriver,以决定我是否可以切换到使用它进行我的浏览器测试(主要来自Watir),其中一个关键的事情就是能够与TinyMCE WYSIWYG编辑器进行交互,作为一些应用程序我使用TinyMCE.我设法让以下解决方案工作 -

@browser = Watir::Browser.new(:firefox)
@browser.goto("http://tinymce.moxiecode.com/tryit/full.php")
autoit = WIN32OLE.new('AutoITX3.Control')
autoit.WinActivate('TinyMCE - TinyMCE - Full featured example')
@browser.frame(:index, 0).body.click
autoit.Send("^a") # CTRL + a to select all
autoit.Send("{DEL}")
autoit.Send("Some new text")
Run Code Online (Sandbox Code Playgroud)

这种方法的缺点是,通过使用autoit,我仍然依赖于Windows,并且跨平台运行测试的能力是webdriver的吸引力之一.

我注意到一些具体的webdriver解决方案,如从下面的主题:

String tinyMCEFrame = "TextEntryFrameName" // Replace as necessary
this.getDriver().switchTo().frame(tinyMCEFrame);
String entryText = "Testing entry\r\n";
this.getDriver().findElement(By.id("tinymce")).sendKeys(entryText);
//Replace ID as necessary
this.getDriver().switchTo().window(this.getDriver().getWindowHandle());
try {
  Thread.sleep(3000);
} catch (InterruptedException e) {

  e.printStackTrace();
}

this.getDriver().findElement(By.partialLinkText("Done")).click(); 
Run Code Online (Sandbox Code Playgroud)

看起来它可能跨平台工作,但我不知道是否可以从Watir-webdriver中访问相同的功能.我的问题是,有没有办法使用watir-webdriver编写,删除和提交到TinyMCE,这不会强制依赖特定支持的浏览器或操作系统?

tinymce webdriver watir watir-webdriver

7
推荐指数
1
解决办法
2093
查看次数

如何在Cucumber表(多行参数)中使用正则表达式来对表进行区分?

我正在使用场景表(多行步骤参数)使用内置的.diff来检查使用黄瓜的屏幕中的一些数据!黄瓜AST表上的方法.

我想检查与正则表达式匹配的内容.

Scenario: One
    Then the table appears as:
    | One   | Two   | Three |
    | /\d+/ | /\d+/ | /\d+/ |
Run Code Online (Sandbox Code Playgroud)

实际的表可能看起来像

| One | Two | Three |
| 123 | 456 | 789   |
Run Code Online (Sandbox Code Playgroud)

这种情况被翻译为"只要有一些数字,我不在乎"

失败的示例步骤实现:

Then /^the table appears as:$/ do |expected_table|
  actual_table  = [['One','Two', 'Three'],['123', '456', '789']]
  expected_table.diff! actual_table
end
Run Code Online (Sandbox Code Playgroud)

错误:

Then the table appears as: # features/step_definitions/my_steps.rb:230
      | One    | Two    | Three  |
      | /\\d+/ | /\\d+/ | /\\d+/ | …
Run Code Online (Sandbox Code Playgroud)

ruby regex cucumber

6
推荐指数
1
解决办法
1636
查看次数

使用SelectByText(部分)与C#Selenium WebDriver绑定似乎不起作用

我在C#中使用Selenium WebDriver Extensions通过部分文本值从选择列表中选择一个值(实际前面有一个空格).我无法使用部分文本匹配来使其工作.我做错了什么或这是一个错误?

可重复的例子:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

namespace AutomatedTests
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            var driver = new FirefoxDriver();
            driver.Navigate().GoToUrl("http://code.google.com/p/selenium/downloads/list");
            var selectList = new SelectElement(driver.FindElement(By.Id("can")));
            selectList.SelectByText("Featured downloads");
            Assert.AreEqual(" Featured downloads", selectList.SelectedOption.Text);
            selectList.SelectByValue("4");
            Assert.AreEqual("Deprecated downloads", selectList.SelectedOption.Text);
            driver.Quit();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

提供错误: OpenQA.Selenium.NoSuchElementException: Cannot locate element with text: Featured downloads

.net c# selenium webdriver selenium-webdriver

6
推荐指数
1
解决办法
4676
查看次数

如何使用mocha中的嵌套测试执行来使测试依赖

我有一个简单的两个测试例子(A,B),其中B依赖于A运行.

如果我使用Mocha,我可以在A中嵌套测试B:

describe.only( 'AB:', function() {

    describe( 'A', function() {
        it( 'A1', function() {
            assert.equal( 1, 2 );
        } );

        describe( 'B', function() {
            it( 'B1', function() {
                assert.equal( 1, 1 );
            } );
        } );
    } );
} );
Run Code Online (Sandbox Code Playgroud)

但即使A失败,A和B都会运行.

这与使用嵌套有什么不同?

describe.only( 'AB:', function() {

    describe( 'A&B', function() {
        it( 'A1', function() {
            assert.equal( 1, 2 );
        } );

        it( 'B1', function() {
            assert.equal( 1, 1 );
        } );
    } );
} );
Run Code Online (Sandbox Code Playgroud)

如果A失败,有没有办法跳过B?

javascript mocha.js

6
推荐指数
2
解决办法
4845
查看次数

带有watir webdriver的Firefox 4:需要帮助使用helperApps.neverAsk来保存CSV而不提示

我学会了如何使用带有watir和webdriver的Firefox 4(在Win7 x64上),设置配置文件项目.例:

profile = Selenium::WebDriver::Firefox::Profile.new
profile["browser.download.useDownloadDir"] = true
profile["browser.download.dir"] = 'D:\\FirefoxDownloads'
profile["browser.helperApps.neverAsk.saveToDisk"] = "application/csv"
driver = Selenium::WebDriver.for :firefox, :profile => profile
browser = Watir::Browser.new(driver)
Run Code Online (Sandbox Code Playgroud)

我尝试使用下面的示例,将CSV文件设置为始终下载到特定目录,从不打开.上面的代码成功设置了自动下载到指定目录的所有文件,但设置browser.helperApps.neverAsk.saveToDisk无效:我仍然得到打开/保存问题.脚本运行后,Firefox窗口仍然打开,我输入关于:config的URL.我可以看到它browser.helperApps.neverAsk.saveToDisk被正确设置为application.csv,但在firefox/options/options/applications中我没有看到CSV文件的条目.看起来真正有效的菜单设置并没有真正与about:config设置绑定.我究竟做错了什么?

firefox webdriver watir firefox4 watir-webdriver

4
推荐指数
1
解决办法
3219
查看次数

如何遍历webdriverjs元素,直到元素具有文本值

我试图弄清楚WebDriverJs中的循环如何与promises一起工作.

假设你有以下html:

  <div id="textelements">
    <span onclick="spanClicked('Rock')">Rock</span>
    <span onclick="spanClicked('Paper')">Paper</span>
    <span onclick="spanClicked('Scissors')">Scissors</span>
  </div>
Run Code Online (Sandbox Code Playgroud)

使用WebDriverJs我想找到带有文本'Scissors'的跨度并单击它.

最简单的方法是确保源html具有适当的标识符,但是说无法更改,给定上面的html,WebDriverJs代码会是什么样子.

我尝试过以下方法:

function clickElementWithText(driver, textValue) {
    driver.findElements(webdriver.By.css('#textelements span')).then(function(spans) {
        for (var i = 0; i < spans.length; i++) {
            var matched = spans[i].getText().then(function(text) {
                console.log('Text value is: ' + text);
                return text === textValue;
            });
            console.log(matched);
            if (matched === true) {
                console.log('clicking!');
                spans[i].click();
                return;
            }
        }
    });
}

var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).build();
driver.get('http://webdriverjsdemo.github.io/');
clickElementWithText(driver, 'Scissors');
Run Code Online (Sandbox Code Playgroud)

问题是匹配true在评估时不相等,即使它应该被设置为true.

有什么想法发生了什么?

javascript selenium webdriverjs

1
推荐指数
1
解决办法
2012
查看次数