量角器" restartBrowserBetweenTests:true"重新启动浏览器,但在此之后不要运行测试

时间:2016-09-15 06:53:50

标签: testing browser protractor restart

我需要在每次" it"之后重启浏览器。 (测试),因此我写了#34; restartBrowserBetweenTests:true"在protractor.config文件中。现在在第一次"它" (测试)完成,浏览器关闭并再次打开(打开我在#34;在每个"之前的网站,但是下一个"它"(测试)没有运行。

我做错了什么?我会很乐意接受任何建议。

我使用"量角器":" 2.5.1"。

谢谢!

添加了:

beforeEach(function () {
    browserUtil.navigateTo(browserUtil.url.main); 
    loginPage.loginAsSample();
});

afterEach(function(){
    browserUtil.deleteCookies();
});

it("'Delete' button is inactive if there are no projects in the list", function() {
    projectPage.clickOnProjectButton();

    expect(projectPage.isProjectPageFormVisibility(true)).toBe(true);
    expect(projectPage.isDeleteBtnDisable()).toBe(true);
});

it("Create new project with template 'A'", function() {
    projectPage.clickOnNewProjectBtn();
    projectPage.clickOnAProject();
    projectPage.clickOnOkBtnProject();

    expect(projectPage.isOpenedProjectVisibility(true)).toBe(true);
});

1 个答案:

答案 0 :(得分:1)

我从未使用<Button Content="Button Content"> <Button.Style> <Style TargetType="Button"> <Style.Resources> <ControlTemplate x:Key="PressedTemplate" TargetType="Button"> <Border Background="LightSkyBlue" BorderBrush="DeepSkyBlue" BorderThickness="4" > <TextBlock Text="Replace this TextBlock with your own content" Foreground="ForestGreen" /> </Border> </ControlTemplate> </Style.Resources> <Style.Triggers> <!-- We can't set Template directly with DiscreteObjectKeyFrame because "Cannot freeze this Storyboard timeline tree for use across threads". So instead we kludge it by setting Tag and putting a trigger on that. --> <Trigger Property="Tag" Value="ButtonHasBeenPressed" > <Setter Property="Template" Value="{StaticResource PressedTemplate}" /> </Trigger> <Trigger Property="IsPressed" Value="True"> <!-- Values set by a Trigger setter are automatically rolled back when the Trigger condition no longer applies. This is not true of values applied by a Storyboard in an enter action. --> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="Tag" > <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="ButtonHasBeenPressed" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> ,但这对我有用:

在protractor.conf中,删除restartBrowserBetweenTests: true

在test.spec.js中,修改restartBrowserBetweenTests: truebeforeEach

afterEach

由于您正在为测试使用页面对象结构,因此您可能希望将beforeEach(function () { browser.get(browserUtil.url.main); }); afterEach(function () { browser.manage().deleteAllCookies(); }); 封装到您的页面对象中。

在定义ProjectPage的地方,我添加:

browser.get(browser.browserUtil.url.main);

如果您采用这种方法,则可以将this.refreshPage = function () { browser.get(browserUtil.url.main); }; 上的通话更改为:

beforeEach