我正在尝试创建一个程序,该程序可以完成订购多米诺披萨的过程。Selenium和Java一直工作到披萨生成器弹出,此时我无法判断如何从中访问任何内容
我正在使用
WebElement element6=driver.findElement(By.xpath("//*[text((="Runchy Thin Crust"]"(;
element6.click((;
我包含了包含披萨构建器信息的div。当我试图访问其中的任何内容时,我总是会出错。我还将构建器内容之前的iframe作为参考。
链接为:https://www.dominos.com/en/pages/order/#/product/S_PIZA/builder/?skipCustomize=真实
<iframe id="utag_200_iframe" height="1" width="1" style="display:none" src="//6189720.fls.doubleclick.net/activityi;src=6189720;type=dom;cat=domin000;ord=4014152329515.799?" aria-hidden="true"></iframe>
<iframe sandbox="allow-scripts allow-same-origin" title="Adobe ID Syncing iFrame" id="destination_publishing_iframe_dominos_0" name="destination_publishing_iframe_dominos_0_name" src="https://dominos.demdex.net/dest5.html?d_nsid=0#https%3A%2F%2Fwww.dominos.com" style="display: none; width: 0px; height: 0px;" class="aamIframeLoaded" aria-hidden="true"></iframe>
<iframe name="xdomain-137d3fdb" id="xdomain-137d3fdb" src="https://order.dominos.com/assets/build/xdomain/proxy.html" style="display:none;" aria-hidden="true"></iframe>
<div id="genericOverlay" class="genericOverlay fulfiller-wizard js-fulfillerWizardOverlay" data-quid="generic-overlay-pizzaBuilderDefaultWrapper" coupon-code="">
<section role="dialog" aria-modal="true" class="card card--overlay js-cardOverlay " data-quid="generic-card-overlay">
<header class="card__header ">
<h1 tabindex="-1" data-quid="generic-card-overlay-title" class="card__title "> Domino's Pizza Builder </h1> <button class="card--overlay__close js-closeButton " data-dpz-track-evt-name="×" data-quid="generic-overlay-close" type="button" aria-label="close"></button> </header>
<div role="document" data-quid="generic-card-overlay-body"
class="card__body">
<div class="card__header js-pizzabuilder--header"> </div>
<div id="pizzaBuilderPage" class="builder--pizza js-pizzaBuilderPage">
<div class="js-pizzabuilder--couponinfo"></div>
<div class="js-progressBar progress js-pizzabuilder--progressbar">
<div class="blockUI is-hidden js-blockUI" style="display: none;">
<!-- -->
</div> <button type="button" class="js-progressBarStep pizzaBuilderSizeCrust progress__step c-sizeCrust is-active" id="sizeCrust" data-quid="progress-bar-sizeCrust" aria-label="Size & Crust" data-dpz-track-evt-label="Size & Crust">Size & Crust</button> <button type="button" class="js-progressBarStep pizzaBuilderCheeseSauce progress__step c-cheeseSauce" id="cheeseSauce" data-quid="progress-bar-cheeseSauce" aria-label="Cheese & Sauce" data-dpz-track-evt-label="Cheese & Sauce">Cheese & Sauce</button> <button type="button" class="js-progressBarStep pizzaBuilderToppings progress__step c-toppings" id="toppings" data-quid="progress-bar-toppings" aria-label="Toppings" data-dpz-track-evt-label="Toppings">Toppings</button> <button type="button"
class="js-progressBarStep pizzaBuilderSides progress__step c-sides" id="sides" data-quid="progress-bar-sides" aria-label="Sides" data-dpz-track-evt-label="Sides">Sides</button></div>
<div class="builder-container">
<div class="js-pizzabuilder--loadsavedpizza"><button class="btn btn--secondary js-btn-loadUnsavedPizza btn--load-unsaved-pizza is-hidden" data-quid="load-previous-pizza" id="loadUnsavedPizza">Load Previous Pizza</button></div>
<div class="js-pizzabuilder--helpOption pizza-builder-help-option media--horizontal"></div>
<div class="visualWrapper js-builderPizzaVisual builder--pizza__visual is-hidden@handheld">
<div id="heightChanger">
<!-- Dynamically change the margin above the visual wrapper when #pizzaSummaryInColumn is larger than 220px -->
</div>
<div class="js-visualPizzaBubbleOverlay visualPizzaBubbleOverlay"></div>
<div id="pizzaCanvas" class="canvas-wrapper">
<!-- --><canvas width="300" height="315" id="crust_canvas" style="display: block; position: absolute; z-index: 0;"></canvas><canvas width="300" height="315" id="mask_canvas" style="display: block; position: absolute; z-index: 15;"></canvas>
<canvas
width="300" height="315" id="X_canvas" style="display: block; position: absolute; z-index: 1;"></canvas><canvas width="300" height="315" id="C_canvas" style="display: block; position: absolute; z-index: 1;"></canvas></div>
</div>
<div class="card--builder-summary js-pizzabuilder--summarybox" id="pizzaSummaryInColumn">
<div class="card card--pop">
<div class="card__header">
<h2 class="card__title"><span>My Pizza</span></h2>
</div>
<div class="card__body grid">
<div class="variantDescription order-summary grid__cell--1">
<div class="order-summary__item">
<h3 class="order-summary__item__title" data-quid="item-title">Large (14") Hand Tossed Pizza</h3>
<ul class="order-summary__item__topping-list" data-quid="item-topping-list">
<li data-quid="whole-topping-list-">Cheese </li>
<li></li>
<li></li>
</ul>
<ul class="order-summary__item__cooking-instructions">
<li></li>
</ul>
</div>
</div>
<p class="quantitySelect grid__cell--1@desktop grid__cell--1/3">Quantity:
<select aria-label="Quantity:" class="quantity" name="S_PIZZA|Quantity">
<!-- -->
<option selected="" value="1">
1
</option>
<option value="2">
2
</option>
<option value="3">
3
</option>
<option value="4">
4
</option>
<option value="5">
5
</option>
<option value="6">
6
</option>
<option value="7">
7
</option>
<option value="8">
8
</option>
<option value="9">
9
</option>
<option value="10">
10
</option>
<option value="11">
11
</option>
<option value="12">
12
</option>
<option value="13">
13
</option>
<option value="14">
14
</option>
<option value="15">
15
</option>
<option value="16">
16
</option>
<option value="17">
17
</option>
<option value="18">
18
</option>
<option value="19">
19
</option>
<option value="20">
20
</option>
<option value="21">
21
</option>
<option value="22">
22
</option>
<option value="23">
23
</option>
<option value="24">
24
</option>
<option value="25">
25
</option>
</select>
</p>
<div class="grid__cell--1@desktop grid__cell--2/3 pizza-builder__add-btn-container"> <button class="btn btn--large js-isNew js-addPizza btn--block c-order-addToOrder" data-quid="add-pizzabuilder-button">Add to Order</button> </div>
</div>
</div>
<div class="js-toppingsMsg is-hidden@handheld is-hidden" data-quid="toppings-msg-desktop"></div>
</div>
<div class="selectionBoard selection-board js-selectionBoard">
<div data-quid="desktop-pizza-builder-btn-container" class="form__control-group--actions--steps js-buttons--prev-next is-hidden@handheld">
<div> <button class="js-prev js-prevnext btn btn--small btn--secondary btn--back c-order-back is-hidden" data-quid="pizza-builder-prev-btn" type="button"> Back </button> </div>
<div> <button class="js-next js-prevnext btn btn--small btn--next c-order-nextStep " data-quid="pizza-builder-next-btn" type="button"> Cheese & Sauce </button> </div>
</div>
<div class="js-toppingsMsg is-hidden@desktop is-hidden" data-quid="toppings-msg-mobile"> </div>
<div class="card card--pop card--pizza-options">
<div class="builderWrapper card__body js-builderWrapper js-pizzabuilder--step-wrapper">
<div id="SizeCrustWrapper" class="grid sizes-wrapper js-sizeCrustWrapper">
<div class="grid__cell--5/8 is-hidden@handheld sizes-wrapper__step-crust">
<h2 class="sizes-wrapper__step-title"> Choose Your Crust </h2>
</div>
<div class="grid__cell--3/8 is-hidden@handheld sizes-wrapper__step-size">
<h2 class="sizes-wrapper__step-title"> Choose Your Size </h2>
</div>
<div class="grid__cell--1 is-hidden@desktop">
<h2 class="sizes-wrapper__step-title"> Choose Your Size & Crust </h2>
<div class="sizes-wrapper__sizes-help-subtitle"> Tap to Select a Size </div>
</div>
<div class="grid__cell--1 grid__cell--3/8@desktop sizes-wrapper__step-1">
<div class="grid">
<div class="sizes-wrapper__size sizes-wrapper__size--10 grid__cell--1@desktop"> <label class="sizes-wrapper__size-label js-size-label" data-quid="pizza-size-10"> <input type="radio" id="pizza_size|10" data-sizecode="10" name="pizza_size" class="sizes-wrapper__size-input js-size" value="" data-quid="pizza-size-10-input"> <span class="sizes-wrapper__size-code sizes-wrapper__size-code--0 sizes-wrapper__size-code--10" data-quid="pizza-size-10-size">10"</span> <span class="sizes-wrapper__size-name" data-quid="pizza-size-10-name">Small</span> </label> </div>
<div class="sizes-wrapper__size sizes-wrapper__size--12 grid__cell--1@desktop"> <label class="sizes-wrapper__size-label js-size-label" data-quid="pizza-size-12"> <input type="radio" id="pizza_size|12" data-sizecode="12" name="pizza_size" class="sizes-wrapper__size-input js-size" value="" data-quid="pizza-size-12-input"> <span class="sizes-wrapper__size-code sizes-wrapper__size-code--1 sizes-wrapper__size-code--12" data-quid="pizza-size-12-size">12"</span> <span class="sizes-wrapper__size-name" data-quid="pizza-size-12-name">Medium</span> </label> </div>
<div class="sizes-wrapper__size sizes-wrapper__size--14 grid__cell--1@desktop"> <label class="sizes-wrapper__size-label js-size-label" data-quid="pizza-size-14"> <input type="radio" id="pizza_size|14" data-sizecode="14" name="pizza_size" class="sizes-wrapper__size-input js-size" value="" data-quid="pizza-size-14-input" checked="true"> <span class="sizes-wrapper__size-code sizes-wrapper__size-code--2 sizes-wrapper__size-code--14" data-quid="pizza-size-14-size">14"</span> <span class="sizes-wrapper__size-name" data-quid="pizza-size-14-name">Large</span> </label> </div>
<div class="sizes-wrapper__size sizes-wrapper__size--16 grid__cell--1@desktop"> <label class="sizes-wrapper__size-label js-size-label" data-quid="pizza-size-16"> <input type="radio" id="pizza_size|16" data-sizecode="16" name="pizza_size" class="sizes-wrapper__size-input js-size" value="" data-quid="pizza-size-16-input"> <span class="sizes-wrapper__size-code sizes-wrapper__size-code--3 sizes-wrapper__size-code--16" data-quid="pizza-size-16-size">16"</span> <span class="sizes-wrapper__size-name" data-quid="pizza-size-16-name">X-Large</span> </label> </div>
</div>
</div>
<div class="grid__cell--1 grid__cell--5/8@desktop grid__cell--1/2@kiosk js-step-2 sizes-wrapper__step-2">
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|10">
<div class="sizes-wrapper__crust"> <input id="crust_type|10HANDTOSS" class="sizes-wrapper__crust-radio js-crust-input c-crust-10SCREEN" data-default-crust="" data-flavorcode="HANDTOSS" data-sizecode="10" name="S_PIZZA|Variant" type="radio" value="10SCREEN" data-quid="crust-input-10SCREEN"> <label for="crust_type|10HANDTOSS" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-10HANDTOSS"> Hand Tossed </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Garlic-seasoned crust with a rich, buttery taste.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|10">
<div class="sizes-wrapper__crust"> <input id="crust_type|10THIN" class="sizes-wrapper__crust-radio js-crust-input c-crust-10THIN" data-flavorcode="THIN" data-sizecode="10" name="S_PIZZA|Variant" type="radio" value="10THIN" data-quid="crust-input-10THIN"> <label for="crust_type|10THIN"
class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-10THIN"> Crunchy Thin Crust </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Thin enough for the optimum crispy to crunchy ratio and square cut to be perfectly sharable.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|10">
<div class="sizes-wrapper__crust"> <input id="crust_type|10GLUTENF" class="sizes-wrapper__crust-radio js-crust-input c-crust-P10IGFZA" data-flavorcode="GLUTENF" data-sizecode="10" name="S_PIZZA|Variant" type="radio" value="P10IGFZA" data-quid="crust-input-P10IGFZA"> <label for="crust_type|10GLUTENF" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-10GLUTENF"> Gluten Free Crust </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Domino's pizza made with a Gluten Free Crust.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|12">
<div class="sizes-wrapper__crust"> <input id="crust_type|12HANDTOSS" class="sizes-wrapper__crust-radio js-crust-input c-crust-12SCREEN" data-default-crust="" data-flavorcode="HANDTOSS" data-sizecode="12" name="S_PIZZA|Variant" type="radio" value="12SCREEN" data-quid="crust-input-12SCREEN"> <label for="crust_type|12HANDTOSS" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-12HANDTOSS"> Hand Tossed </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Garlic-seasoned crust with a rich, buttery taste.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|12">
<div class="sizes-wrapper__crust"> <input id="crust_type|12THIN" class="sizes-wrapper__crust-radio js-crust-input c-crust-12THIN" data-flavorcode="THIN" data-sizecode="12" name="S_PIZZA|Variant" type="radio" value="12THIN" data-quid="crust-input-12THIN"> <label for="crust_type|12THIN"
class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-12THIN"> Crunchy Thin Crust </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Thin enough for the optimum crispy to crunchy ratio and square cut to be perfectly sharable.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|12">
<div class="sizes-wrapper__crust"> <input id="crust_type|12NPAN" class="sizes-wrapper__crust-radio js-crust-input c-crust-P12IPAZA" data-flavorcode="NPAN" data-sizecode="12" name="S_PIZZA|Variant" type="radio" value="P12IPAZA" data-quid="crust-input-P12IPAZA">
<label
for="crust_type|12NPAN" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-12NPAN"> Handmade Pan </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Two layers of cheese, toppings to the edge, baked in a pan for a crust that is golden and crispy with a buttery taste.</span> </label>
</div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts" data-crusts-for="pizza_size|14">
<div class="sizes-wrapper__crust"> <input id="crust_type|14BK" class="sizes-wrapper__crust-radio js-crust-input c-crust-PBKIREZA" data-flavorcode="BK" data-sizecode="14" name="S_PIZZA|Variant" type="radio" value="PBKIREZA" data-quid="crust-input-PBKIREZA">
<label
for="crust_type|14BK" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-14BK"> Brooklyn Style </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Hand stretched to be big, thin and perfectly foldable.</span> </label>
</div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts" data-crusts-for="pizza_size|14">
<div class="sizes-wrapper__crust"> <input id="crust_type|14HANDTOSS" class="sizes-wrapper__crust-radio js-crust-input c-crust-14SCREEN" data-default-crust="" data-flavorcode="HANDTOSS" data-sizecode="14" name="S_PIZZA|Variant" type="radio" value="14SCREEN" data-quid="crust-input-14SCREEN"> <label for="crust_type|14HANDTOSS" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-14HANDTOSS"> Hand Tossed </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Garlic-seasoned crust with a rich, buttery taste.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts" data-crusts-for="pizza_size|14">
<div class="sizes-wrapper__crust"> <input id="crust_type|14THIN" class="sizes-wrapper__crust-radio js-crust-input c-crust-14THIN" data-flavorcode="THIN" data-sizecode="14" name="S_PIZZA|Variant" type="radio" value="14THIN" data-quid="crust-input-14THIN"> <label for="crust_type|14THIN"
class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-14THIN"> Crunchy Thin Crust </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Thin enough for the optimum crispy to crunchy ratio and square cut to be perfectly sharable.</span> </label> </div>
</div>
<div class="sizes-wrapper__crusts-container js-crusts is-hidden" data-crusts-for="pizza_size|16">
<div class="sizes-wrapper__crust"> <input id="crust_type|16BK" class="sizes-wrapper__crust-radio js-crust-input c-crust-P16IBKZA" data-default-crust="" data-flavorcode="BK" data-sizecode="16" name="S_PIZZA|Variant" type="radio" value="P16IBKZA" data-quid="crust-input-P16IBKZA"> <label for="crust_type|16BK" class="sizes-wrapper__crust-label"> <span class="sizes-wrapper__crust-name" data-quid="pizza-builder-crust-name-16BK"> Brooklyn Style </span> <span class="sizes-wrapper__crust-description" data-quid="pizza-builder-crust-desc">Hand stretched to be big, thin and perfectly foldable.</span> </label> </div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="js-cookingInstructions cooking-instructions card card--pop card--pizza-options">
<div class="card__body grid">
<div class="grid__cell--1">
<h3 class="section-title collapsed">Special Instructions</h3> <a class="button--cooking-instructions js-cookingInstructionsToggle collapsed" data-dpz-track-evt-name="special instructions-expanded" data-dpz-track-evt-category="button" href="#">+</a>
<div id="cookingInstructionsContainer"
class="grid is-hidden js-cookingInstructionsContainer clr">
<div class="cooking-instruction-group product grid__cell--1 grid__cell--1/4@desktop grid__cell--1/3@widescreen" data-variant="14SCREEN">
<h3 class="step-title">Bake</h3>
<div class="cooking-instruction-group__toggles">
<div class="row cooking-instruction-group__toggle"> <label> <input class="js-selectCookingInstruction" type="radio" data-code="WD" data-default="false" data-description="Well Done" name="BAKE"> <span class="btn--toggle">Well Done</span> </label> </div>
<div class="row cooking-instruction-group__toggle">
<label> <input class="js-selectCookingInstruction" type="radio" data-code="NB" data-default="true" data-description="Normal Bake" name="BAKE"> <span class="btn--toggle">Normal Bake</span> </label> </div>
</div>
</div>
<div class="cooking-instruction-group product grid__cell--1 grid__cell--1/4@desktop grid__cell--1/3@widescreen" data-variant="14SCREEN">
<h3 class="step-title">Seasoning</h3>
<div class="cooking-instruction-group__toggles">
<div class="row cooking-instruction-group__toggle"> <label> <input class="js-selectCookingInstruction" type="radio" data-code="GO" data-default="true" data-description="Garlic-Seasoned Crust" name="SEASONING"> <span class="btn--toggle">Garlic-Seasoned Crust</span> </label> </div>
<div class="row cooking-instruction-group__toggle"> <label> <input class="js-selectCookingInstruction" type="radio" data-code="NGO" data-default="false" data-description="No Garlic-Seasoned Crust" name="SEASONING"> <span class="btn--toggle">No Garlic-Seasoned Crust</span> </label> </div>
</div>
</div>
<div class="cooking-instruction-group product grid__cell--1 grid__cell--1/4@desktop grid__cell--1/3@widescreen" data-variant="14SCREEN">
<h3 class="step-title">Cut</h3>
<div class="cooking-instruction-group__toggles">
<div class="row cooking-instruction-group__toggle"> <label> <input class="js-selectCookingInstruction" type="radio" data-code="PIECT" data-default="true" data-description="Pie Cut" name="CUT"> <span class="btn--toggle">Pie Cut</span> </label> </div>
<div class="row cooking-instruction-group__toggle">
<label> <input class="js-selectCookingInstruction" type="radio" data-code="SQCT" data-default="false" data-description="Square Cut" name="CUT"> <span class="btn--toggle">Square Cut</span> </label> </div>
<div class="row cooking-instruction-group__toggle">
<label> <input class="js-selectCookingInstruction" type="radio" data-code="UNCT" data-default="false" data-description="Uncut" name="CUT"> <span class="btn--toggle">Uncut</span> </label> </div>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-quid="handheld-pizza-builder-btn-container" class="form__control-group--actions--steps js-buttons--prev-next is-hidden@desktop">
<div> <button class="js-prev js-prevnext btn btn--small btn--secondary btn--back c-order-back is-hidden" data-quid="pizza-builder-prev-btn" type="button"> Back </button> </div>
<div> <button class="js-next js-prevnext btn btn--small btn--next c-order-nextStep " data-quid="pizza-builder-next-btn" type="button"> Cheese & Sauce </button> </div>
</div>
</div>
<p class="is-hidden@handheld"> The Pizza Builder will always show a large pizza. If you choose a different size, the topping amounts will vary. The deliciousness, however, will not.</p>
</div>
</div>
</section>
</div>
看起来您的元素在pizza builder框架/窗口下。至少我在网站上看到的是提供的xpath和链接。对我来说,xpath工作时发现单选按钮很好://input[@id='crust_type|14THIN']
如果经常点击不起作用,你可以尝试使用JavaScriptExecutor。点击操作应该看起来很像:
JavascriptExecutor jse = (JavascriptExecutor) driver;
WebElement element6 = driver.findElement(By.xpath("//*[text()='Crunchy Thin Crust']"));
jse.executeScript("arguments[0].click();", element6);