如何防止jQuery UI使用`draggable`属性更改HTML元素?(How to prevent jQuery UI change HTML elements with `draggable` attribute?)
示例: http : //codepen.io/anon/pen/wMGbYv 。 如您所见,jQuery UI丢弃
draggable
属性并添加它自己的类。 如何防止这种顽皮并创建具有draggable
属性的元素而不丢弃jQuery UI(最好使用jQuery)?Example: http://codepen.io/anon/pen/wMGbYv. As you can see, jQuery UI discards
draggable
attribute and adds it's own classes. How to prevent this naughtiness and create element withdraggable
attribute without discarding jQuery UI (preferably using jQuery)?
原文:https://stackoverflow.com/questions/34377555
最满意答案
我尝试确保我的specflow场景不共享任何数据,如果我可以在每次测试之间显式重新生成整个数据库架构。
这可确保只有您在测试中安排的数据才在数据库中
因此,我创建了一个单独的Given步骤,要么运行所有步骤来创建一个帐户(您可以以编程方式调用这些步骤),或者有一个单独的Given步骤,它会使所有使用您需要的信息的数据发生短路。
我还注意到您在测试中明确关闭了浏览器。 我为启动/停止Selenium的Web创建了BeforeScenario / AfterScenario标记。 因此,您的测试只需要测试实际功能,而不是测试Selenium的启动/停止。
public class SeleniumController { public static readonly SeleniumController Instance = new SeleniumController(); public static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10); public IWebDriver Selenium { get; private set; } private void Trace(string message) { Console.WriteLine("-> {0}", message); } public void Start() { if (Selenium != null) return; string appUrl = ConfigurationManager.AppSettings["AppUrl"]; var options = new ChromeOptions(); options.AddArgument("test-type"); Selenium = new ChromeDriver(options); Selenium.Manage().Timeouts().ImplicitlyWait(DefaultTimeout); Trace("Selenium started"); } public void Stop() { if (Selenium == null) return; try { Selenium.Quit(); Selenium.Dispose(); } catch (Exception ex) { Debug.WriteLine(ex, "Selenium stop error"); } Selenium = null; Trace("Selenium stopped"); } }
场景标签
public static class SeleniumSupport { private static bool ReuseWebSession { get { return ConfigurationManager.AppSettings["ReuseWebSession"] == "true"; } } [BeforeScenario("web")] public static void BeforeWebScenario() { SeleniumController.Instance.Start(); } [AfterScenario("web")] public static void AfterWebScenario() { if (!ReuseWebSession) SeleniumController.Instance.Stop(); } }
抽象步骤基类访问selenium webdriver
public abstract class SeleniumStepsBase { protected IWebDriver Selenium { get { return SeleniumController.Instance.Selenium; } } }
I try to make sure that my specflow scenarios don't share any data, and if i can explicitly regenerate the whole database schema when possible between each test.
This ensures that only data that you have arranged in the test is in the database
So I'd create a separate Given step that either runs through all the steps to create an account (you can call those steps programatically) or have a separate Given step that short circuits all that seeds the db with the information you need.
I also notice that you explicitly close your browser in your tests. I create a BeforeScenario/AfterScenario tag for the web that starts/stops Selenium. So that your tests only need to test the actual functionality and not the starting/stopping of Selenium.
public class SeleniumController { public static readonly SeleniumController Instance = new SeleniumController(); public static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10); public IWebDriver Selenium { get; private set; } private void Trace(string message) { Console.WriteLine("-> {0}", message); } public void Start() { if (Selenium != null) return; string appUrl = ConfigurationManager.AppSettings["AppUrl"]; var options = new ChromeOptions(); options.AddArgument("test-type"); Selenium = new ChromeDriver(options); Selenium.Manage().Timeouts().ImplicitlyWait(DefaultTimeout); Trace("Selenium started"); } public void Stop() { if (Selenium == null) return; try { Selenium.Quit(); Selenium.Dispose(); } catch (Exception ex) { Debug.WriteLine(ex, "Selenium stop error"); } Selenium = null; Trace("Selenium stopped"); } }
scenario tags
public static class SeleniumSupport { private static bool ReuseWebSession { get { return ConfigurationManager.AppSettings["ReuseWebSession"] == "true"; } } [BeforeScenario("web")] public static void BeforeWebScenario() { SeleniumController.Instance.Start(); } [AfterScenario("web")] public static void AfterWebScenario() { if (!ReuseWebSession) SeleniumController.Instance.Stop(); } }
abstract steps base class to access selenium webdriver
public abstract class SeleniumStepsBase { protected IWebDriver Selenium { get { return SeleniumController.Instance.Selenium; } } }
相关问答
更多-
如何使用MSTest从命令行运行SpecFlow方案?(How do you run SpecFlow scenarios from the command line using MSTest?)[2022-03-05]
在现场,specflow测试只是普通的mstest单元测试。 所以你应该可以用类似的方法来运行它们: 运行特定场景: mstest /testcontainer:tests.dll /test:GivenMyScenarioWhenIDoSomeStuff 要运行多个特定场景,您可以多次使用/ test标志: mstest /testcontainer:tests.dll /test:GivenMyScenarioWhenIDoSomeStuff /test:GivenMyScenarioWhenIDoS ... -
BDD SpecFlow场景类型(BDD SpecFlow Scenario types)[2023-08-03]
场景大纲和场景模板只是同义词。 没有区别。 两者都定义了scenario_outline步骤。 英语SpecFlow关键词中有几个同义词。 例如, 示例和场景或功能和业务需求 。 为不同的语言定义了不同的同义词,并在国际化文件中指定。 例如英语: "en": { "name": "English", "native": "English", "feature": "Feature|Business Need|Ability", "background": "Background", "s ... -
BDD SpecFlow场景(BDD SpecFlow Scenarios)[2022-11-21]
场景: Given a name "test" When I click on the SEARCH button Then the result will be | name | last name | test | fulano | test | siclano 码: [Then("The result will be")] public void ThenTheResultWillBe(Table table) { //check that the result contains all ... -
我会选择选项2 - 您正在测试一些用例,您不应该涉及另一个测试测试的用例。 测试包括一些驱动测试的代码和用于执行测试的数据。 因此,如果您需要测试的特殊数据,您应该预先准备它们,而不是通过应用程序逻辑创建它们。 I would go with option 2 - you are testing some use case and you should not involve use cases tested by another tests. Test consists of some code driv ...
-
每个功能的多个方案都可以,只要它们在逻辑上位于同一区域。 如果您试图解决不同的用例,我可能会建议将其作为新功能。 在您的情况下,看起来两个场景在同一功能下可以很好地适应。 场景大纲类似于NUnit中的TestCase ,如果相同的场景结构只需要采用不同的参数,则只能使用它。 SpecFlow github站点在 此处有关于场景概述的良好文档。 我将总结下面的代码示例。 给定一个特征中的两个场景: Scenario: eat 5 out of 12 Given there are 12 cucumbers ...
-
如何编写彼此跟随并共享数据的specflow场景?(How to write specflow scenarios that follow each other and share data?)[2022-10-30]
我尝试确保我的specflow场景不共享任何数据,如果我可以在每次测试之间显式重新生成整个数据库架构。 这可确保只有您在测试中安排的数据才在数据库中 因此,我创建了一个单独的Given步骤,要么运行所有步骤来创建一个帐户(您可以以编程方式调用这些步骤),或者有一个单独的Given步骤,它会使所有使用您需要的信息的数据发生短路。 我还注意到您在测试中明确关闭了浏览器。 我为启动/停止Selenium的Web创建了BeforeScenario / AfterScenario标记。 因此,您的测试只需要测试实际功 ... -
看看你是如何编写这个问题的,看起来你是Specflow的新手。 问题是Specflow不是一种编程语言。 实际上,当您第一次开始查看它时,它的一些语言组件可能会受到妨碍。 如果您正确地遵循BDD方法,那么程序员不应该编写功能文件。 应该是商务人士,这就是语言如此开放的原因。 只需要几个占位符来提供功能和方案名称,然后在每行的开头添加一个简单的单词来表示它是设置操作(给定),还是操作(When)或测试(Then)。 例如,作为开发人员,我可能会提出以下内容作为示例。 Feature: Waking kids ...
-
我的同事给了我们一个很好的解决方案:情景大纲: Scenario Outline: Channels on different protocols Given The test server is up and running And The previously obtained channel list is reset When I request a list of radio channels for the
and Then the resulting ... -
我认为这对你选择的跑步者来说更是一个问题。 SpecFlow从测试文件为您生成测试,但不会运行它们。 您可能能够指导您的测试跑步者按照您要求的顺序运行场景。 不过,我的建议是,你不要试图订购你的测试。 每个场景应该完全独立于其他场景,以便运行测试的顺序对结果没有影响。 我想这取决于你的意思是“好”,如果他们按照特定的顺序运行。 :) I think that's more of a question for your test runner of choice. SpecFlow generates the ...
-
第一:SpecFlow中不支持Pairwise属性。 您必须自己创建每个可能的组合并填写示例表。 第二:你的例子中有一个场景。 这将是一个测试。 你想要的是一个带有示例表的场景大纲。 在这里查看相关信息: http : //specflow.org/documentation/Using-Gherkin-Language-in-SpecFlow/ 完全披露:我是SpecFlow开发人员之一。 First: There is no support of the Pairwise attribute in Sp ...