我有一些测试自动化代码从存储在本地机器上的环境变量中读取一些值,如下所示:
Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User);
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 Azure Pipelines 在管道执行期间创建此变量,然后在我的测试自动化代码中读取它。使用 YAML 文件。
我在 Azure Pipeline 的 VS 测试步骤中读取此变量。因此,如果我设置该变量,它必须在 Azure Pipeline 的整个生命周期内。
也尝试了下面的代码,但由于此错误而失败:
azure-pipelines.yml (Line: 39, Col: 1, Idx: 1252) - (Line: 39, Col: 1, Idx: 1252):扫描一个简单的键时,找不到预期的':'。
# Create a secret variable
- powershell: |
Write-Host '##vso[task.setvariable variable=sauce.userName;issecret=true]abc'
# Attempt to output the value in various ways
- powershell: |
# Using an input-macro:
Write-Host "This works: $(sauce.userName)"
# Using the env var directly:
Write-Host "This does not work: …Run Code Online (Sandbox Code Playgroud) continuous-integration azure azure-devops azure-pipelines-build-task azure-pipelines
所以我遇到了与下面这个HTML交互的问题.我无法打开弹出窗口并使用不同的Selenium Webdriver命令关闭它.虽然我在这里寻找一个特定的解决方案,但任何有关处理Angular JS的一般提示也将受到赞赏.我相信问题的根本原因是我不知道使用Selenium Webdriver自动化Angular的好方法.
我正在使用C#,但我会从任何编程语言中获取任何有用的信息,因为我总是可以改进解决方案.
我正在尝试与此弹出按钮进行交互,但未成功:uib-popover-template ="'/ app/student/assessment/directives/templates/shortTextPopupTemplate.html'"
<div class="line ttsBorder">“<span style="font-style:italic;">And be it further enacted</span><span style="display: inline;">, That in all that territory ceded</span><span short-text-popup="" accession-number="VH209006" class="ng-isolate-scope" ng-non-bindable=""><a uib-popover-template="'/app/student/assessment/directives/templates/shortTextPopupTemplate.html'" popover-is-open="ctrl.isVisible" popover-trigger="none" popover-placement="auto top" tabindex="0" title="Shows more information." ng-click="buttonOnClick($event)" ng-keydown="buttonOnKeydown($event)" ng-class="['stpu-button', {disabled: ctrl.isDisabled, active: ctrl.isVisible}]" class="ng-scope stpu-button" style="z-index: 3;"></a></span> by France to the United States . . . which lies north of thirty?six degrees and thirty minutes north latitude . . . slavery . . . shall be, and is hereby, forever prohibited.”</div>Run Code Online (Sandbox Code Playgroud)
这是我尝试失败的原因:
//attempt 1
var elements = Driver.FindElements(By.XPath("//*[@class='line ttsBorder']"));
//attempt 2 …Run Code Online (Sandbox Code Playgroud) 有人可以帮我解决此错误消息吗?我不明白为什么演员不起作用:
消息:System.InvalidCastException:无法将类型为“ Castle.Proxies.ObjectProxy”的对象转换为类型为“ Automation.Pages.ToolbarElements.ElementsWithActiveState.ActiveStateElements”的对象。
这是我的测试:
[TestFixture]
[Category("unit")]
class ActiveStateElementBehaviorTests
{
[Test]
public void GetCurrentElementState_StateIsActive_ReturnActive()
{
var moqElement = new Mock<IActiveState>();
moqElement.Setup(x => x.IsElementInActiveState()).Returns(() => true);
var behavior = new ActiveStateElementBehavior(moqElement.Object);
behavior.GetCurrentElementState().Should().BeEquivalentTo(ElementState.Active);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
public class ActiveStateElementBehavior : IElementStateBehavior
{
public ActiveStateElementBehavior(IActiveState toolbarElement)
{
Element = (ActiveStateElements)toolbarElement;
}
public ENAEPToolbarElement Element { get; }
public ElementState GetCurrentElementState()
{
var element = (ActiveStateElements) Element;
return element.IsElementInActiveState() ? ElementState.Active :
element.IsButtonInEnabledState() ? ElementState.Default :
ElementState.Disabled;
}
}
public interface IActiveState
{
bool …Run Code Online (Sandbox Code Playgroud) 我有这个要返回的对象值,我想将其转换为可以检查和操作的有用的JSON对象。最终,我的目标是验证的价值观username和accessKey。但是有2件事情使这件事不起作用。Double {{使它成为无效的JSON,sauce:options并且不能转换为类中的属性。
{{
"browserName": "MicrosoftEdge",
"browserVersion": "latest",
"platformName": "Windows 10",
"sauce:options": {
"username": "test",
"accessKey": "123"
}
}}
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的:
string output = JsonConvert.SerializeObject(SauceSession.Options.ConfiguredEdgeOptions);
Run Code Online (Sandbox Code Playgroud)
这SauceSession.Options.ConfiguredEdgeOptions将返回我上面提到的那个对象。
回过头来: Newtonsoft.Json.JsonSerializationException:“从'OpenQA.Selenium.Edge.EdgeOptions'的'BinaryLocation'获取值时出错。”
我还根据建议尝试了此操作:
var serialized = JsonConvert.SerializeObject(SauceSession.Options.ConfiguredEdgeOptions);
Run Code Online (Sandbox Code Playgroud)
并返回此Newtonsoft.Json.JsonSerializationException:“从'OpenQA.Selenium.Edge.EdgeOptions'上的'BinaryLocation'获取值时出错。”