2015-10-20 63 views
1

点击我有,我都想尽已知的方式点击这里元素有几个:不能元素

var areaMap = $('[data-bind="click: campusMap"]'); 
var areaMap = browser.driver.findElement(By.cssSelector("div.campus-map.panel > div.panel-footer > button.btn.btn-browse")).click(); 
var areaMap = element(by.cssContainingText('button.btn', "View Area Map")); 

//and this way too 

browser.executeScript('arguments[0].click()', areaMap.getWebElement()); 
browser.actions().mouseMove(areaMap).click().perform(); 

我不知道如何使这个要素互动,能。

的HTML看起来像这样:

<div class="campus-map panel" data-bind="click: campusMap"> 
 
    <div class="title">Area Map</div> 
 
    <div class="panel-content"> 
 
    <div id="googleContainer" style="position: relative; background-color: rgb(229, 227, 223); overflow: hidden;"> 
 
     <div class="gm-style" style="position: absolute; left: 0px; top: 0px; overflow: hidden; width: 100%; height: 100%; z-index: 0;"> 
 
     <div style="position: absolute; left: 0px; top: 0px; overflow: hidden; width: 100%; height: 100%; z-index: 0; cursor: pointer;"> 
 
      <div style="margin-left: 5px; margin-right: 5px; z-index: 1000000; position: absolute; left: 0px; bottom: 0px;"> 
 
      <div class="gmnoprint" style="z-index: 1000001; position: absolute; right: 166px; bottom: 0px; width: 121px;"> 
 
       <div style="background-color: white; padding: 15px 21px; border: 1px solid rgb(171, 171, 171); font-family: Roboto,Arial,sans-serif; color: rgb(34, 34, 34); box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.2); z-index: 10000002; display: none; width: 256px; height: 118px; position: absolute; left: 36px; top: 5px;"> 
 
       <div class="gmnoscreen" style="position: absolute; right: 0px; bottom: 0px;"> 
 
        <div class="gmnoprint gm-style-cc" style="z-index: 1000001; position: absolute; -moz-user-select: none; right: 95px; bottom: 0px;" draggable="false"> 
 
        <div class="svg-controls" style="z-index: 0; position: absolute; bottom: 13px; right: 0px;"> 
 
         <div class="gm-style-cc" draggable="false" style="-moz-user-select: none; position: absolute; right: 0px; bottom: 0px;"> 
 
         </div> 
 
        </div> 
 
        </div>

+0

@Sam谢谢你的清洁:) –

+0

你尝试点击ng吗? –

+0

@ruby我不能改变html,我不认为这是一个角度页面。我在页面上有按钮,这个只是出于任何原因不想被点击 –

回答

0

你的示例代码有没有在你的HTML例子存在的元素...所以我不是100%肯定你”重新尝试点击。但是,假设它的第一个div,并假设它是可见,这个选择应该工作:

var areaMap = $('div.campus-map.panel');

,或者如果这是不可见的,也许这(因为标题应该是可见的):

var areaMap = $('div.campus-map.panel div.title');

或用文字:

var areaMap = element(by.cssContainingText('div.title', "Area Map"));