Everything inside an "it" function is an independent test. What you need to do is put shared steps in a "beforeEach" function
describe('Check pdf popup', function() {
beforeEach(function() {
element('.navbar a:eq(3)').click();
});
it('We should see the pdf popup', function() {
expect(element('.modal h4:visible').text()).toMatch(/Email PDF/);
});
it('Cancel should dispel the pdf popup', function() {
// exit pdf box
element('input[value="Cancel"]').click();
expect(repeater('.modal h4:visible').count()).toBe(0);
});
it('if customer email not set, display input for email', function() {
expect(repeater('.modal #pdfemail:visible').count()).toBe(1);
expect(repeater('.modal #pdfcustomercheckbox:visible').count()).toBe(0);
});
});
You can nest additional "describe" blocks inside each other, containing additional "beforeEach" functions, having the effect of issuing consecutive commands.
describe('fuel comparison', function() {
beforeEach(function() {
element("#gasvsdiesel").click();
});
it('should switch to Fuel Comparison calculator', function() {
expect(element('.brand').text()).
toBe("Fuel Comparison");
});
describe('changing gas price', function() {
beforeEach(function() {
input("compareFuelPrice").enter("5.888");
});
it('should change fuelinfo text to show reset link', function() {
element('#content .nav-pills a[tap-click="tab=\'calculations\'"]').click();
expect(element("#fuelinfo span:visible").text()).toBe("(Click here to set fuel prices to California defaults)");
});
});
});