我正在进行功能测试,我收到了错误
InvalidArgumentException:当前节点列表为空
这是我的代码
1
我认为这是错误的:
$ form = $ submitButton-> form($ requestContent);
请注意,$ requestContent值来自隐藏的输入类型,它们都在form标记内。
答案 0 :(得分:1)
您必须将按钮的文字提供给$crawler->selectButton()
。
// For a given HTML button:
// <input type="button" value="Upload File" />
// or
// <button type="button">Upload File</button>
$crawler->selectButton("Upload File");
旁注,您的正则表达式'/\/nextPage'
无效。您需要添加结束/
- &gt; '/\/nextPage/' // This will match the exact string: "/nextPage"
答案 1 :(得分:1)
您还没有发布HTML,所以现在我假设你的HTML如下:
$submitButton = $crawler->selectButton('Submit');
改变
#Load TFS PowerShell Snap-in
if((Get-PSSnapIn -Name Microsoft.TeamFoundation.PowerShell -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin Microsoft.TeamFoundation.PowerShell
}
#Load Reference Assemblies
$Tfs2015AssembliesPath="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer"
Add-Type -Path "$Tfs2015AssembliesPath\Microsoft.TeamFoundation.Client.dll"
Add-Type -Path "$Tfs2015AssembliesPath\Microsoft.TeamFoundation.Common.dll"
Add-Type -Path "$Tfs2015AssembliesPath\Microsoft.TeamFoundation.WorkItemTracking.Client.dll"
Function GetWorkItems{
param([string]$teamProjectName,[string]$address)
$credentials = New-Object System.Net.NetworkCredential("[user name]", "[password]")
$tfsCollection = New-Object Microsoft.TeamFoundation.Client.TfsTeamProjectCollection((New-Object System.URI($address)))
$wis = $tfsCollection.GetService([Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore])
$wiqlQT="select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.Tags] from WorkItemLinks where (Source.[System.TeamProject] = @project and Source.[System.WorkItemType] = 'Epic' and Source.[System.State] <> '' and Source.[System.AreaPath] = 'Agile2015Starain' and Source.[System.IterationPath] = 'Agile2015Starain') and ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') and (Target.[System.TeamProject] = @project and Target.[System.WorkItemType] <> '') mode (Recursive)"
$variableValues=@{}
$variableValues.Add("project", $teamProjectName)
$query=New-Object Microsoft.TeamFoundation.WorkItemTracking.Client.Query($wis,$wiqlQT,$variableValues)
$witCollection=$query.RunLinkQuery()
#logical to save data to excel or csv
$wits=New-Object "System.Collections.Generic.List[Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem]"
$title=""
$id=0
Foreach($witItem in $witCollection)
{
$id=$witItem.SourceId
if($id -gt 0)
{
$parentWorkItem = $wits | where {$_['ID'] -eq $id}
$t = $parentWorkItem.Title;
}
$currentWorkItem = $wis.GetWorkItem($witItem.TargetId);
$t = $currentWorkItem.Title;
$wits.Add($currentWorkItem);
}
}
GetWorkItems "Agile2015Starain" "https://[your vsts name].visualstudio.com"
因为selectButton()接受按钮值而不是id或name。
确保这对您有所帮助。