本文介绍了TDD用于与Django / Splinter进行整合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用队列小部件设置上传测试。
我使用进行浏览器测试,但我找不到一种方法实现它。 Splinter有一些方法来附加文件,但只有当它是一个简单的文件字段。
另一种方式是点击按钮浏览文件,并选择文件...但我不认为可能使用Splinter(或硒),是吗?
或者拖放文件。

I'm trying to set up tests for a upload using the plupload queue widget.I'm using Splinter for in-browser test, but I couldn't find a way to make it happen. Splinter has some methods to attach files, but only if it's a simple file field.Another way would be click the button to browse the files, and choose the file... but I don't think it's possible using Splinter (or selenium), is it?Or with drag-n-drop of the files.

任何人都有任何建议自动化这些测试的最佳方法?

Anyone has any suggestion of the best way to automatize theses tests?

推荐答案

可以使用Selenium-WebDriver在PLUpload控件上自动执行用户操作。请在下面找到WebDriver C#代码,点击Flash按钮对象,并使用键盘事件选择文件

Its possible to automate user actions done on PLUpload control using Selenium- WebDriver. Please find the WebDriver C# code below, which clicks on a flash button object and selects a file using keyboard events,

using System;
using System.Windows.Forms;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Interactions;
using NUnit.Framework;
namespace BusinessCreation
{
    class PlUpload
    {
        static void Main(string[] args)
        {
               IWebDriver driver = new FirefoxDriver();
               driver.Navigate().GoToUrl("http://www.plupload.com/example_queuewidget.php");
               driver.FindElement(By.XPath("//object[@data='/plupload/js/plupload.flash.swf']")).Click();
               SendKeys.SendWait(@"C:\Users\Public\Pictures\Sample Pictures\Dock.jpg");
               SendKeys.SendWait(@"{Enter}");
         }
    }
}

这篇关于TDD用于与Django / Splinter进行整合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 05:13