首页 > 解决方案 > 如何指定这个特定的 xpath

问题描述

我想替换.oe_structure类下的内容,但我对 div 感到困惑,因为有些类名相同。我尝试从 Chrome Devtools 获取 xpath,但总是出错。

<template id="contactus" name="Contact us" page="True">
    <t t-call="website.layout">
      <div id="wrap">
        <div class="oe_structure"/>
            <div class="container">
                <h1>Contact us</h1>
                <div class="row">
                    <div class="col-md-8">
                        <div class="oe_structure"> <!-- How to get this path? --> 
                            <div>
                                <p>Contact us about anything related to our company or services.</p>
                                <p>We'll do our best to get back to you as soon as possible.</p>
                            </div>
                        </div>
                        <div class="text-center mt64" name="mail_button">
                            <a t-attf-href="mailto:{{ res_company.email }}" class="btn btn-primary" id="o_contact_mail">Send us an email</a>
                        </div>
                    </div>
                    <div class="col-md-4 mb32">
                        <t t-call="website.company_description"/>
                    </div>
                </div>
            </div>
        <div class="oe_structure"/>
      </div>
    </t>
</template>

标签: xmlxpath

解决方案


你也可以使用这个 xpath

//div[@class='row']//div[@class='oe_structure']

推荐阅读