为什么isPresent()无法按预期工作?

时间:2018-10-17 13:58:59

标签: protractor cucumber bdd assert chai

我想检查在某些情况下DOM中没有下拉列表。 为此,我创建了此功能:

using System;
using System.IO;
using System.Text;
using System.IO.Packaging;
using System.Xml.Linq;

namespace ConsoleApp1
{
    class Program
    {
        private static void Main()
        {
            using (var package = Package.Open("fix.docx", FileMode.Open, FileAccess.ReadWrite, FileShare.None))
            {
                //Add drawing
                var drawingPartUri = PackUriHelper.CreatePartUri(new Uri("/word/drawings/drawing1.xml", UriKind.Relative));
                var drawingPart = package.CreatePart(drawingPartUri, System.Net.Mime.MediaTypeNames.Text.Xml);
                using (var mStream = new MemoryStream(Encoding.ASCII.GetBytes("<c:userShapes xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><ns8:relSizeAnchor xmlns:ns8=\"http://schemas.openxmlformats.org/drawingml/2006/chartDrawing\"><ns8:from><ns8:x>0.52502</ns8:x><ns8:y>0.25595</ns8:y></ns8:from><ns8:to><ns8:x>0.52502</ns8:x><ns8:y>0.49702</ns8:y></ns8:to><ns8:cxnSp macro=\"\"><ns8:nvCxnSpPr><ns8:cNvPr id=\"4\" name=\"Straight Arrow Connector 3\"/><ns8:cNvCxnSpPr/></ns8:nvCxnSpPr><ns8:spPr><a:xfrm xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:off x=\"3590925\" y=\"819150\"/><a:ext cx=\"0\" cy=\"771525\"/></a:xfrm><a:prstGeom xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" prst=\"straightConnector1\"><a:avLst/></a:prstGeom><a:ln xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:headEnd type=\"triangle\"/><a:tailEnd type=\"triangle\"/></a:ln></ns8:spPr><ns8:style><a:lnRef xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" idx=\"1\"><a:schemeClr val=\"accent1\"/></a:lnRef><a:fillRef xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" idx=\"0\"><a:schemeClr val=\"accent1\"/></a:fillRef><a:effectRef xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" idx=\"0\"><a:schemeClr val=\"accent1\"/></a:effectRef><a:fontRef xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" idx=\"minor\"><a:schemeClr val=\"tx1\"/></a:fontRef></ns8:style></ns8:cxnSp></ns8:relSizeAnchor></c:userShapes>")))
                {
                    if (drawingPart != null)
                        using (var pStream = drawingPart.GetStream())
                        {
                            mStream.CopyTo(pStream);
                        }
                }

                //Create relationship
                var chartUri = PackUriHelper.CreatePartUri(new Uri("/word/charts/chart1.xml", UriKind.Relative));
                var chartPart = package.GetPart(chartUri);
                var rel = chartPart.CreateRelationship(drawingPartUri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes");

                //Modify chart
                var doc = XDocument.Load(chartPart.GetStream());
                XNamespace c = "http://schemas.openxmlformats.org/drawingml/2006/chart";
                XNamespace r = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
                var userShapes = new XElement(c + "userShapes", new XAttribute(r + "id", rel.Id));
                doc.Root?.LastNode.AddAfterSelf(userShapes);
                doc.Save(chartPart.GetStream());
            }
        }
    }
}

问题在于下拉列表是否存在并不重要,期望值始终会传递期望语句。 参见下面的代码:

Scenario Outline: Flexibility Use Case. US31032. When I select the Product Line, 
                  Program it will be blanked/greyed out. (Program="NULL")

    Given I am on the application
    Then application is running
    When <productLine> has value <productLineValue>
    Then <dropdown> not clickable
    And content of the template is not empty

Examples:
  |productLine       |productLineValue  | dropdown  |
  |templateSelection |AT_CURTAIL        | whatever  |

有什么想法吗?

谢谢。

0 个答案:

没有答案