Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我知道图像按钮的ID,但仍然可以';不要点击它_Javascript_Html_Selenium_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Javascript 我知道图像按钮的ID,但仍然可以';不要点击它

Javascript 我知道图像按钮的ID,但仍然可以';不要点击它,javascript,html,selenium,selenium-webdriver,selenium-chromedriver,Javascript,Html,Selenium,Selenium Webdriver,Selenium Chromedriver,我知道图像按钮的ID,但仍然无法使用以下命令单击: driver.findElement(By.id("its Id")).click() 无法提供网站链接,因为它不是公共网站,但正在粘贴指定webelement的HTML <div ondragstart="var e=window.event;e.cancelBubble=true;e.returnValue=false;return false;" draggable="false" id="WD0191" ct="B" lsdat

我知道图像按钮的ID,但仍然无法使用以下命令单击:

driver.findElement(By.id("its Id")).click()
无法提供网站链接,因为它不是公共网站,但正在粘贴指定webelement的HTML

<div ondragstart="var e=window.event;e.cancelBubble=true;e.returnValue=false;return false;" draggable="false" id="WD0191" ct="B" lsdata="{4:'Add\x20All',10:true,12:'\x2fsap\x2fpublic\x2fbc\x2fur\x2fnw5\x2fthemes\x2f\x7ecache\x2d20171002133000\x2fBase\x2fbaseLib\x2fsap_belize\x2fsvg\x2flibs\x2fSAPGUI\x2dicons.svg\x23s_pagedo'}" lsevents="{Press:[{ResponseData:'delta',ClientAction:'submit'},{}]}" role="button" aria-labelledby="WD0191-arialabel" title="Add All " tabindex="0" ti="0" class="lsButton lsTbarBtnStd urInlineMetricTop urNoUserSelect urBtnRadius  lsButton--onlyImage  urBtnImgBgColor lsButton--design-standard urBtnStd">
  <span id="WD0191-cnt" class="urNoUserSelect lsButton--content lsControl--centeraligned " style="pointer-events:none;">
    <svg data-sap-ls-svg-inline="true" data-sap-ls-svg-inlinehtmlexchange="true" id="WD0191-img" alt="Add All " tabindex="-1" ti="-1" focusable="false" preserveAspectRatio="none" viewBox="0 0 100 100" class="urSvgAppIconMetric urSvgAppIconColorBase urSvgAppIconVAlign urImgBtn lsButton__image" style="nop:nop;margin-top: 0px;;nop:nop;">
      <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#_SAPGUI-icons_1_s_pagedo"></use>
    </svg>
    <span class="lsButton--onlyImage-pusher" style="display:inline-block;width:0;">&nbsp;</span>
  </span>
  <span id="WD0191-arialabel" style="display:none;visibility:hidden;">Add All</span>
</div> 
但没有结果

更新:按钮的用途以及在大图中它是哪个div标签。
此按钮位于一个表内,该表在表的第一部分分为两部分。您可以根据某些搜索条件获取结果,如果结果相关,则使用此图像按钮将其复制到表的第二部分。

您可以尝试使用element.submit()
如果这不起作用,请尝试使用JavaScript executor

是否可以尝试使用element.submit()
如果这不起作用,请尝试使用JavaScript executor

尝试使用JavascriptExecutor:

    WebElement ele1 = driver.findElement(By.id("ITS ID"));
    JavascriptExecutor clickbtn = (JavascriptExecutor)driver;
    clickbtn.executeScript("arguments[0].click();", ele1);

尝试使用JavascriptExecutor:

    WebElement ele1 = driver.findElement(By.id("ITS ID"));
    JavascriptExecutor clickbtn = (JavascriptExecutor)driver;
    clickbtn.executeScript("arguments[0].click();", ele1);

我得到了答案,事实上,我是在表1中获取数据之前单击图像按钮的,因此在有任何数据传递到第二个表之前单击了该按钮,这给我的印象是,尽管按钮被单击,但单击按钮后数据仍然不会从表1传递到表2。现在,我们已经添加了显式等待5000,并按预期工作

不过谢谢大家的意见

@Sneha Shinde谢谢。。在尝试使用javascript executor解决方案时了解了此等待问题


虽然在我的例子中,simple element.click()在等待之后也能工作。

我得到了答案,事实上,我是在表1中获取数据之前单击图像按钮的,因此在有任何数据传递到第二个表之前单击了该按钮,这给我的印象是,尽管按钮被单击,但单击按钮后数据仍然不会从表1传递到表2。现在,我们已经添加了显式等待5000,并按预期工作

不过谢谢大家的意见

@Sneha Shinde谢谢。。在尝试使用javascript executor解决方案时了解了此等待问题


虽然在我的例子中,simple element.click()在放置wait之后也可以工作。

您检查过这段html代码是否在一个框架中吗?我在提供的代码中看到四个不同的ID。您使用哪个ID单击?@j.barrio是的,它在一个框架中已经切换到该框架,它还有其他元素。单击()正在工作。@MivaScott我使用的是“WD0191”这个ID,它是用于div tag的可能重复的。您检查过这个html代码是否在一个框架中吗?我在提供的代码中看到四个不同的ID。您使用哪个ID单击?@j.barrio是的,它在一个框架中已经切换到该框架,它还有其他元素。单击()正在工作。@MivaScott我使用的是“WD0191”这个ID,它是div tag的,可能与我尝试过的元素重复。submit()但它给出了一个错误声明“没有这样的元素:元素不在表单中,因此无法提交。”。要设置上下文,此按钮位于一个表中,该表在表的第一部分分为两部分,您根据搜索获取结果,如果结果相关,则使用此图像按钮将其复制到表的第二部分。我尝试了执行元素。提交()但是它给出了一个错误,声明“没有这样的元素:元素不在表单中,因此无法提交。”。要设置上下文,此按钮位于一个表中,该表在表的第一部分分为两部分,您根据搜索获取结果,如果结果相关,则使用此图像按钮将其复制到表的第二部分。