本文的目的是介绍selenium:元素不可点击的详细情况,特别关注selenium元素不可点击的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解selenium:元素不
本文的目的是介绍selenium:元素不可点击的详细情况,特别关注selenium元素不可点击的相关信息。我们将通过专业的研究、有关数据的分析等多种方式,为您呈现一个全面的了解selenium:元素不可点击的机会,同时也不会遗漏关于c# – Selenium Wait不等待Element可点击、org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素 ... 在点(376,846)不可点击、Python Selenium ChromeDriver 错误消息:元素不可交互、Python selenium sendkeys 元素不可交互的知识。
本文目录一览:- selenium:元素不可点击(selenium元素不可点击)
- c# – Selenium Wait不等待Element可点击
- ... 在点(376,846)不可点击">org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素 ... 在点(376,846)不可点击
- Python Selenium ChromeDriver 错误消息:元素不可交互
- Python selenium sendkeys 元素不可交互
selenium:元素不可点击(selenium元素不可点击)
这个问题是由于chrome driver
总clicks
的中间element
在试图忠实于什么实际用户一样。所以我在想这种方法:
首先,而不是查找元素,然后单击:
driver.fineElement(By.xpath("bla bla")).click()
编写单击以下内容的通用函数WebElement
:
def clickOnWebElement(WebElement webElement) { int counter = 0; boolean isClicked = false; Thread.sleep(1000);try { while (count < 2 && !isClicked) { if (count == 0) { webElement.click() isClicked = true; } else if (count == 1) { Actions action = new Actions(driver); action.moveToElement(webElement).click().perform(); isClicked = true; } else if (count == 2) { JavascriptExecutor js =(JavascriptExecutor)driver; js.executeScript("window.scrollTo(0,"element.getLocation().x+")"); webElement.click(); isClicked = true; } } }catch(Exception ex) { count++; Thread.sleep(2000); }}
然后,当发生此异常时,请尝试以其他方式单击。
您认为这种方法可行吗?
答案1
小编典典请仔细阅读此堆栈溢出答案以更好地理解。
更新 我们也可以尝试
There are many Conditions that we can use withing Webdriver tests.1. visibilityOf(WebElement element) : An expectation for checking that an element, known to be present on the DOM of a page, is visible.2. visibilityOfElementLocated(By locator) : An expectation for checking that an element is present on the DOM of a page and visible.In the above two conditions we are waiting for an element to be present on the DOM of a page and also visible. These works fine only when the element is loaded completely.
也请尝试如下
尝试使用Y坐标单击
WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));// Scroll the browser to the element''s Y position((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");// Click the elementelementToClick.click();
尝试使用X坐标单击
WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));// Scroll the browser to the element''s X position((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().x+")");// Click the elementelementToClick.click();
希望这对您有帮助
c# – Selenium Wait不等待Element可点击
webdriverwait wait = new webdriverwait(Driver.Instance,TimeSpan.FromSeconds(30)); wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("addinspectionButton"))); var button = Driver.Instance.FindElement(By.Id("addinspectionButton")); button.Click();
这不起作用. click事件永远不会被触发. selenium脚本不会抛出异常,提示ID为“addinspectionButton”的元素不存在.它只是无法点击它.如果我添加一个Thread.Sleep(3000)在wait语句和我得到按钮元素句柄的行之间它可以工作.
我在这里没有正确使用ExpectedConditions.ElementToBeClickable吗?
解决方法
我的解决方案是单击按钮,检查预期结果,然后重复,如果预期结果尚未在DOM中.
由于预期的结果是打开一个表单,我像这样轮询DOM:
button.Click();//click button to make form open var forms = Driver.Instance.FindElements(By.Id("inspectionDetailsForm"));//query the DOM for the form var times = 0;//keep tabs on how many times button has been clicked while(forms.Count < 1 && times < 100)//if the form hasn't loaded yet reclick the button and check for the form in the DOM,only try 100 times { button.Click();//reclick the button forms = Driver.Instance.FindElements(By.Id("inspectionDetailsForm"));//requery the DOM for the form times++;// keep track of times clicked }
... 在点(376,846)不可点击" alt="org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素 ... 在点(376,846)不可点击">
... 在点(376,846)不可点击">org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素 ... 在点(376,846)不可点击
如何解决org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素<a href="/url"> ... </a>在点(376,846)不可点击?
我有一个自动脚本,试图转到页面,单击链接,然后确保显示登录/注册门,因为我是匿名用户。
由于无法找到我的链接,因此我无法进行登机验证。我收到以下错误:org.openqa.selenium.ElementClickInterceptedException:元素单击被拦截:元素...在点(376,846)不可单击。其他元素将获得点击:
我试图通过cssSelector和xpath的不同版本(绝对,相对等)来定位此链接。
我发现了以下线程:
ElementClickInterceptedException: Message: element click intercepted: Element <label> is not clickable with Selenium and Python
并且已尝试按照https://www.selenium.dev/documentation/en/webdriver/waits/#explicit-wait执行等待 我不得不删除了Duration.ofSeconds,因为Java 3中似乎已弃用了它。我还尝试了在获得URL之后和找到元素之后直接进行等待。
我也尝试了隐式等待。我仍然遇到相同的错误。我是Java的新手,所以可以提供一些帮助!
这是我的代码:
package packagename;
import org.junit.Test;
import org.junit.Before;
import org.hamcrest.MatcherAssert;
import org.junit.After;
import static org.hamcrest.CoreMatchers.is;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.webdriverwait;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.JavascriptExecutor;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;
public class classname {
private WebDriver driver;
JavascriptExecutor js;
@Before
public void setUp() throws MalformedURLException {
driver = new RemoteWebDriver(new URL("webdriverurl"),DesiredCapabilities.chrome());
js = (JavascriptExecutor) driver;
new HashMap<String,Object>();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void name() {
driver.get("url");
new webdriverwait(driver,(30))
.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[contains(text(),''Abe Ikubo & Katayama'')]")));
driver.findElement(By.xpath("//a[contains(text(),''Abe Ikubo & Katayama'')]")).click();
MatcherAssert.assertthat(driver.findElement(By.xpath("//xpath")).getText(),is("text"));
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
Python Selenium ChromeDriver 错误消息:元素不可交互
不要使用 ìd
来查找元素,而是尝试使用 xpath
。
driver.find_element_by_xpath("the_xpath_to_the_element")
在 Chrome 中,您只需使用开发人员工具即可找到您的元素,然后右键单击该元素并单击复制 xpath。
Python selenium sendkeys 元素不可交互
以下代码有效。我使用 webdriverwait 等待主输入出现,与您的代码相比,主要区别在于我点击了 ID main-input
的跨度,但 send_keys
事件被发送到 textarea 子项作为孙子。您不能将密钥发送到 span
标签。
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
driver_path = '<YOUR DRIVER PATH>'
driver = webdriver.Chrome(driver_path)
expression = '2+2'
driver.get('https://pt.symbolab.com/')
span = WebDriverWait(driver,10).until(
EC.presence_of_element_located((By.ID,"main-input"))
)
textarea = WebDriverWait(driver,10).until(
EC.presence_of_element_located((By.XPATH,"//*[@id=\"main-input\"]/span[1]/textarea"))
)
span.click()
textarea.send_keys(expression)
关于selenium:元素不可点击和selenium元素不可点击的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于c# – Selenium Wait不等待Element可点击、org.openqa.selenium.ElementClickInterceptedException:元素点击被拦截:元素 ... 在点(376,846)不可点击、Python Selenium ChromeDriver 错误消息:元素不可交互、Python selenium sendkeys 元素不可交互的相关知识,请在本站寻找。
本文标签: