
33 Cal.3d 778 (1983)
661 P.2d 1088
191 Cal. Rptr. 8
RICHARD A. CHRISTENSEN et al., Plaintiffs and Appellants,
v.
DEWOR DEVELOPMENTS et al., Defendants and Appellants.
Docket No. L.A. 31691.
Supreme Court of California.
May 2, 1983.
*780 COUNSEL
F. Glenn Nichols for Plaintiff and Appellants.
Feinberg & Wolf, Isman, Wolf & Feinberg and Arthur R. Bergen for Defendants and Appellants.
OPINION
GRODIN J.
We grapple here with a variation on a recurring and often vexing theme concerning waiver of the right to arbitrate. Specifically, we consider whether a party retains the right to insist upon arbitration after he has filed a lawsuit over admittedly arbitrable disputes, for the asserted purpose of discovering his opponent's legal theories, and has pursued that litigation through successive demurrers, abandoning it only a day before a scheduled hearing on the adequacy of his amended complaint. While this court has in other contexts been reluctant to find waiver, partly in recognition of this state's policy to encourage arbitration as an alternative to litigation, we conclude that the state's policy would be undermined, rather than served, by permitting this sort of deliberate end-run around the arbitral process. Accordingly, we hold that the trial court properly found waiver on the facts of this case.

Factual and Procedural Background
On October 28, 1977, plaintiffs Richard A. and Rose J. Christensen entered into a construction contract with defendants Dewor Developments and Wladimir Worotko, pursuant to which defendants, as prime contractors, undertook construction of a 2-story, 10-unit apartment building, to be completed within 180 working days after commencement of construction. Paragraph 17 of the contract provided for arbitration, in accordance with American Arbitration Association rules, of "[a]ny controversy arising out of the construction of the project ... or regarding the interpretation of this contract or any subcontract or sub-subcontract."
Construction began September 11, 1978, and, according to plaintiffs' allegations, was not substantially completed until November 13, 1979. On December 23, 1980, plaintiffs filed against defendants a 32-page complaint stating 7 causes of action including breach of contract, "promissory estoppel," intentional and negligent misrepresentation, intentional and negligent interference with prospective economic advantage, and "pierce of corporate veil." Buried on page 17, in paragraph 83 of the complaint, plaintiffs noted the existence of the arbitration provision in the construction agreement, and asserted that plaintiffs *781 "are therefore entitled to have the present action arbitrated in accordance with said contractual provision."
If filing a 32-page complaint seemed a strange way to preserve arbitration rights, plaintiffs later cleared the mystery by asserting it was their intent to "arbitrate this case from its inception as evidenced by their specific reservations of their arbitration rights," and that the purpose of filing the complaint was to "obtain from the defendants an answer and affirmative defenses so that the Christensens could have some feel for what the Defendants' position would be at arbitration...."
This novel strategy backfired when defendants, instead of answering the complaint, filed a demurrer, and matters got still worse for plaintiffs when the trial court sustained the demurrer as to each cause of action except the first, which it struck on its own motion.
Apparently undaunted, plaintiffs filed a trimmed-down but still substantial amended complaint stating the same seven causes of action. The amended complaint, like the original, acknowledged the arbitrability of the dispute and asserted the right to arbitrate.
Defendants again filed a demurrer, this time responding to the complaint's assertions regarding arbitration with an allegation that plaintiffs' right to arbitrate had been waived. One day before the hearing set on the second demurrer, plaintiffs dismissed their complaint "without prejudice" and, two months later, filed a petition to compel arbitration in the Los Angeles County Superior Court. That court denied the petition, finding that plaintiffs, by litigating their complaint through a demurrer and a first amended complaint for the purpose of "unilateral discovery" and at all times intending to dismiss, had acted in bad faith, and had thereby waived the right to arbitrate. The court also denied defendants' claim for attorney's fees pursuant to contract. Both parties have appealed.

Discussion

I. Waiver of the Right to Arbitrate

(1) Determination by a trial court that "[t]he right to compel arbitration has been waived by the petitioner" is one of three statutory grounds for withholding an order to arbitrate an otherwise arbitrable controversy. (Code Civ. Proc., § 1281.2, subd. (a).) Such a determination is ordinarily one of fact which "`if supported by substantial evidence, is binding on an appellate court.'" An appellate court will reverse a finding of waiver by the trial court only "`in cases where the record before the trial court establishes a lack of waiver as a matter of *782 law.'" (Keating v. Superior Court (1982) 31 Cal.3d 584, 605 [183 Cal. Rptr. 360, 645 P.2d 1192] [U.S. Supreme Ct. jur. postponed until hg. on the merits, sub nom. Southland Corp. v. Keating (1983) ___ U.S. ___ (74 L.Ed.2d 948, 103 S.Ct. 721), quoting Doers v. Golden Gate Bridge etc. Dist. (1979) 23 Cal.3d 180, 185 [151 Cal. Rptr. 837, 588 P.2d 1261].)
In Keating, our most recent pronouncement on the subject, we summarized certain of the principles applicable to determination of waiver. We reconfirmed that "[a]rbitration is strongly favored. Courts will closely scrutinize any claims of waiver [citations] and `"indulge every intendment to give effect to [arbitration] proceedings." [Citations.]' Moreover, the burden of proof is `heavy' and rests on the party seeking to establish waiver [citations] which `is not to be lightly inferred.' [Citations.]" (Keating v. Superior Court, supra, 31 Cal.3d at pp. 604-605.) We explained that while there is no "single test" for establishing waiver, "the relevant factors include whether the party seeking arbitration (1) has `previously taken steps inconsistent with an intent to invoke arbitration,' (2) `has unreasonably delayed' in seeking arbitration, (3) or has acted in `bad faith' or with `wilful misconduct.'" (Keating, supra, 31 Cal.3d at p. 605, quoting Davis v. Blue Cross of Northern California (1979) 25 Cal.3d 418, 425-426 [158 Cal. Rptr. 828, 600 P.2d 1060].) And, we stressed the "significance of the presence or absence of prejudice. Waiver does not occur by mere participation in litigation; there must be `judicial litigation of the merits of arbitrable issues' (Doers v. Golden Gate Bridge etc. Dist., supra, 23 Cal.3d at p. 188), although `waiver could occur prior to a judgment on the merits if prejudice could be demonstrated' (id., at p. 188, fn. 3)." (Keating, supra, 31 Cal.3d at p. 605.)
Applying these principles in Keating we concluded that the record supported the trial court's refusal to find waiver on the part of a defendant who, confronted with several lawsuits, engaged in certain preliminary skirmishes before moving to compel arbitration. Here, it is the plaintiff who seeks to change course, and the difference is significant. A party who brings suit over a dispute which he has agreed to arbitrate has acted in violation of his agreement, while a defendant in such a suit has done no legal wrong. The defendant may seek a stay, or dismissal, of the action (see Charles J. Rounds Co. v. Joint Council of Teamsters No. 42 (1971) 4 Cal.3d 888, 899 [95 Cal. Rptr. 53, 484 P.2d 1397]), and it is normally desirable that he do so promptly if he intends to do so at all; but, given the "`overriding ... policy favoring arbitration ... [M]ere delay in seeking a stay of the proceedings without some resultant prejudice to a party [citation] cannot carry the day.'" (Keating, supra, 31 Cal.3d at pp. 605-606, quoting from Carcich v. Rederi A/B Nordie (2d Cir.1968) 389 F.2d 692, 696; cf. Note, Contractual Agreements to Arbitrate Disputes: Waiver of the Right to Compel Arbitration (1979) 52 So.Cal.L.Rev. 1513, 1546, suggesting a more stringent standard.) Neither the trial court, nor we, found such prejudice in Keating.
*783 Similar considerations apply when the plaintiff brings his action in good faith, as in Doers v. Golden Gate Bridge etc. Dist., supra, 23 Cal.3d 180. Doers, who had been employed by Greyhound Lines as a baggage clerk at the Santa Rosa Greyhound terminal, suffered a loss in regular employment and job security when the district began commute bus service from Santa Rosa to San Francisco, and Greyhound converted its Santa Rosa terminal from a company operation to a "commission agency." Doers brought suit in federal district court against the district and the Amalgamated Transit Union (which had contracts with both Greyhound and the district) claiming rights under the Urban Mass Transit Act of 1964 (49 U.S.C. § 1601 et seq.). When his federal action was dismissed for lack of subject matter jurisdiction, he joined with the union in seeking arbitration of his grievances under the union's contract with the district. The trial court denied their joint petition to compel arbitration on the ground that both Doers' and the union's rights to arbitrate were waived when Doers brought his action in federal court; but we reversed, holding that the mere filing of the action did not result in waiver. (23 Cal.3d at p. 188.)
Doers is distinguishable from this case in a number of respects. Doers was not a direct party to the contract containing the arbitration procedures; hence, his filing of a lawsuit was not in violation of any contractual obligation on his part. Indeed, he was not even an employee of the employer party to the agreement; hence, he may well have had no reason to know, when he filed his suit, that there existed between the district and the union a contract which would provide him with a forum for arbitration of his statutory claim to job security. In any event, there was no showing that Doers brought his lawsuit in knowing disregard of a provision for arbitration. Under such circumstances, the policies favoring arbitration are best served by preserving the right to arbitrate, absent a showing of prejudice, and in Doers we so held.
(2) Here, by contrast, plaintiffs were parties to an agreement containing a broad provision for arbitration, and they were concededly aware both of the existence of the arbitration provision and its applicability to the particular dispute. Indeed, they candidly admit that they intended all along to avail themselves of arbitration, but filed their superior court action only to obtain a set of verified pleadings from defendants which would reveal their opponents' legal strategies and theories. Among the principal reasons motivating persons to agree to arbitrate their differences is likely to be the avoidance of the courtroom with its attendant delays, costs, and publicity, and the avoidance of procedures associated with the formal litigation of causes.[1] For a party to file a lawsuit in order to discover his opponent's theories thus tends to defeat the expectations of *784 the parties, in addition to imposing unnecessary and inappropriate burdens upon already congested court calendars. Such procedural gamesmanship provides ample support for the trial judge's conclusion that plaintiffs filed their action in bad faith, and by doing so waived their right to arbitrate. "The courtroom may not be used as a convenient vestibule to the arbitration hall so as to allow a party to create his own unique structure combining litigation and arbitration." (De Sapio v. Kohlmeyer (1974) 35 N.Y.2d 402 [362 N.Y.S.2d 843, 321 N.E.2d 770, 773].)
We also reject plaintiffs' argument that defendants were not prejudiced by their conduct. (See Doers, supra, 23 Cal.3d at p. 188, fn. 3.) In addition to the fact that defendants incurred nearly $300 in court costs and over $2,000 in attorney's fees, the lengthy nature of the delays associated with plaintiffs' abortive attempt at litigation has, we are told, resulted in faded memories and lost records by subcontractors. Plaintiffs do not convincingly dispute this purported prejudice and, in the context of the fastmoving construction industry, we do not doubt that it is real. The trial court so found.
Plaintiffs complain that consigning them to litigation at this stage will be counterproductive, by imposing upon both them and defendants  and the court system  a substantial and unnecessary waste of time and money. Plaintiffs, however, are hardly in a position to complain of that result, the dilemma being one entirely of their own making. Defendants, by invoking the defense of waiver, have opted for litigation over arbitration as it is their right to do under the circumstances. And whatever burden the court system will have to bear as a result of this litigation is a small price to pay for the deterrence of further abuse. We conclude that the trial court's order denying plaintiff's petition to compel arbitration should be affirmed.[2]

II. Dismissal  With or Without Prejudice

Since the issue was vigorously argued below and is asserted by defendants on appeal, and will undoubtedly be raised in the event plaintiffs seek to renew their litigation, we briefly discuss whether plaintiffs properly dismissed their complaint without prejudice. We observe at the outset that if defendants' contention  that the dismissal should have been with prejudice  is accepted, plaintiffs would be left without any remedy whatsoever.
Defendants, after plaintiffs had dismissed their superior court action without prejudice, moved to vacate the dismissal and enter a new dismissal with prejudice. The trial court, in conjunction with its denial of the petition to compel *785 arbitration, ruled that under Wells v. Marina City Properties, Inc. (1981) 29 Cal.3d 781 [176 Cal. Rptr. 104, 632 P.2d 217], which had just been decided and the effect of which had been fully briefed, a voluntary dismissal after the filing of an amended complaint and before a ruling on the demurrer to that amended complaint is permissible.
The pertinent passage of Wells declares: "We conclude, therefore, that once a general demurrer is sustained with leave to amend and plaintiff does not so amend within the time authorized by the court or otherwise extended by stipulation or appropriate order, he can no longer voluntarily dismiss his action pursuant to [Code of Civil Procedure] section 581, subdivision 1, even if the trial court has yet to enter a judgment of dismissal on the sustained demurrer. (Anticipating another possible source of procedural confusion [citation], we note that such right of voluntary dismissal, which is not barred until expiration of plaintiff's time to amend after the sustaining of the demurrer, would also not be impaired prior to a decision sustaining the demurrer.)" (29 Cal.3d at pp. 789-790, italics in original.)
Defendants interpret the dictum in this passage to mean that after a demurrer is sustained, and a demurrer to a new, amended complaint is filed, as here, plaintiff can no longer voluntarily dismiss. A contrary interpretation, they assert, could result in successive litigation in another court after the plaintiff dismisses without prejudice.
We do not agree with this interpretation of Wells. (3) Before a ruling on the amended complaint, it cannot be said that there has been a "decision sustaining the demurrer." (Wells, supra, 29 Cal.3d at p. 790.) It follows that, as Wells intimates, plaintiffs had the right to dismiss the complaint without prejudice before any decision on the demurrer to the first amended complaint. The first amended complaint had replaced the original complaint, and until a demurrer to that amended complaint had been sustained, there was no decision sustaining the demurrer. Our interpretation of Wells is supported by the cases and the commentators. (See United Shippers, Inc. v. Superior Court (1980) 104 Cal. App.3d 359, 362 [162 Cal. Rptr. 871], disapproved on other grounds in Wells, supra, 29 Cal.3d at p. 789 [plaintiff has right to dismiss his action even though demurrer to complaint has been argued and submitted]; Home Real Estate Co. v. Winnants (1919) 39 Cal. App. 643, 645 [179 P. 534] [citing Goldtree v. Spreckels (1902) 135 Cal. 666 (67 P. 1091), court declares that when leave to amend is granted, plaintiff may either dismiss, amend, or allow judgment to be entered; if plaintiff had filed a timely amendment, "it is not disputed that it immediately might have required a dismissal to be entered under the permission of section 581 of the Code of Civil Procedure"]; 4 Witkin, Cal. Procedure (2d ed. 1971 & 1981 supp.) Proceedings Without Trial, § 51, pp. 2716-2717.)
*786 As we pointed out, the interpretation defendants urge would leave plaintiffs without any remedy whatsoever, either in superior court or in arbitration. This is a Draconian result we are quite unprepared to require. Defendants had the option of staying in court or going to arbitration; they cannot have their cake and eat it too.

III. Attorney's Fees

Defendants cross-appeal, contending they should be awarded attorney's fees both at the trial and appellate level.
The trial court specifically rejected defendants' request for attorney's fees in connection with the petition to compel arbitration, striking the portion of the judgment, drafted by defendants, which had provided for an award of fees.
Civil Code section 1717, as amended effective January 1, 1982, (some 10 days prior to the judgment herein) declares that when a contract provides for attorney's fees, such fees can be awarded in a sum "fixed by the court, upon notice and motion by a party." Paragraph 11 of the contract recites that if either party becomes involved in litigation arising out of the contract, "the court in such litigation, or in a separate suit, shall award reasonable costs and expenses, including attorney fees, to the party justly entitled thereto."
Although defendants did not technically comply with Civil Code section 1717's requirement of notice and motion for attorney's fees, this was apparently not the ground for the trial judge's refusal to grant attorney's fees. We note that the amended version of section 1717  and the requirement of notice and motion  did not come into effect until 10 days prior to the trial court's judgment, and after all procedural steps in the case were completed. Moreover, although defendants did not comply with the "notice and motion" requirement, they did submit the issue to the court for decision, in the form of a memorandum of costs and disbursements, declaration in support of attorney's fees, and points and authorities in support thereof. Under these circumstances, the spirit, if not the letter, of the amended statute was complied with.
(4) Although the trial court retains great discretion to fix the amount of attorney's fees, it was an abuse of discretion, in the face of section 1717 and the contractual provision for attorney's fees for the prevailing party, to deny them altogether. Defendants shall be allowed to move, upon notice to plaintiffs, for attorney's fees in connection with the petition to compel arbitration.
Defendants shall also be allowed to make a motion in superior court for attorney's fees on appeal. The superior court should, after the remittitur is filed, hear such an application for attorney's fees for services rendered on appeal, and *787 fix the reasonable amount thereof. (American City Bank v. Zetlen (1969) 272 Cal. App.2d 65, 67 [61 Cal. Rptr. 311].)

Conclusion
We conclude that plaintiffs, by filing two complaints aimed at discovering their opponents' legal theories and thereby precipitating lengthy delays, have waived their right to arbitrate. The portion of the judgment denying plaintiffs' petition to compel arbitration is therefore affirmed. Plaintiffs properly dismissed their superior court lawsuit without prejudice. The portion of the judgment denying defendants' claim for attorney's fees pursuant to contract is reversed. Defendants shall be permitted to make a motion in superior court for attorney's fees at trial and on appeal. Defendants shall recover costs on appeal.
Bird, C.J., Mosk, J., Kaus, J., Broussard, J., and Reynoso, J., concurred.
Richardson, J., concurred in the result.
The petition of plaintiffs and appellants for a rehearing was denied June 23, 1983.
NOTES
[1]  Parties to arbitration agreements are free to incorporate discovery procedures if they choose to do so but, except in the case of personal injury and wrongful death claims (Code Civ. Proc., § 1283.1, subd. (a)), their failure to do so is taken as an agreement to operate without such procedures. (Code Civ. Proc., § 1283.1, subd. (b).)
[2]  The parties raise a host of other issues, including the parties to the arbitration agreement and its scope, which it is unnecessary to reach in view of our conclusion.
