selenium 相关问题

Selenium是一种流行的开源工具,用于自动化Web浏览器。使用此标记时,还要包含您正在使用的特定组件的其他标记,例如selenium-webdriver用于语言绑定,selenium-ide,selenium-grid等。

如何将 chromedriver 包含在 pyinstaller 中?

我正在使用 pyinstaller 创建 python 脚本的可执行文件。 在脚本中我使用这些导入: 从硒导入网络驱动程序 从 selenium.webdriver.chrome.options 导入选项 等等....

回答 2 投票 0

如果未找到元素,则毫无例外地检查元素

我正在尝试探测页面是否存在特定元素,因为它会改变我的进程中的条件。我使用 .find_element_by_xpath 来查找元素并且它工作正常,但是如果...

回答 3 投票 0

Python-Selenium:Chrome 无头设置不适用于“WebDriverWait”

以下代码可以在真实浏览器中通过,但在无头浏览器中则不行。 而真实: 尝试: #明确等待 打印(“尝试4”) WebDriverWait(驱动程序, 10).until(EC.

回答 3 投票 0

在 Selenium 中使用 java 从另一个 CSV 文件读取用户名和密码后将用户名和密码写入 CSV 文件

我已经编写了从 CSV 文件读取内容(用户名和密码)的代码。现在,我需要将这些内容写入另一个 CSV 文件。请帮我提出一个好的建议。 公开课

回答 2 投票 0

CSS选择器-如何定位父元素

有没有办法在CSS选择器中定位父元素? 我正在使用下面的代码,但我没有获取父元素。 WebElement we=dr.findElement(By.cssSelector("div[id='gf-BIG']:parent")); ...

回答 4 投票 0

使用 Python 的 Webdriver Manager 时出现 Selenium ChromeDriver 问题

运行此代码时: 从硒导入网络驱动程序 从 selenium.webdriver.common.keys 导入密钥 从 webdrivermanager.chrome 导入 ChromeDriverManager 驱动程序 = webdriver.Chrome(

回答 0 投票 0

如何在Python中使用slenium来点击按钮?

我尝试找到如何单击按钮以使用selenium中的python接受cookie, 我用了很多劝告但没有任何效果:( 这是元素: 我尝试找到如何单击按钮以使用selenium中的python接受cookie, 我用了很多劝告,但没有任何效果:( 这是元素: <button class="button primary cookie-button" ng-click="$ctrl.allowAllCookies()"> <span class="ng-binding">Todas las cookies</span> </button> 我用在其他: wait = WebDriverWait(driver, 5) time.sleep(2) wait.until(EC.presence_of_element_located((By.ID, "onetrust-banner-sdk"))) element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="onetrust-accept-btn-handler"]'))) element.click() 这是按钮的所有代码: <div class="text-center cookie-controls"> <button class="button primary cookie-button" ng-click="$ctrl.allowCookiesSelection()"> <span class="ng-binding">Permitir selección</span> </button> <button class="button primary cookie-button" ng-click="$ctrl.allowAllCookies()"> <span class="ng-binding">Todas las cookies</span> 但是现在我没有id可以使用,我不知道如何使用。 根据您在问题中呈现的 XML,您可以使用多个 XPath 定位器找到此按钮。 例如尝试这个: wait = WebDriverWait(driver, 20) wait.until(EC.element_to_be_clickable((By.XPATH, '//button[contains(@ng-click,"allowAllCookies")]'))).click() 另一种方法如下: buttons = driver.find_element(By.TAGNAME, 'button') for button in buttons: if button.text() == 'Accept Cookies' cookies_Button = button cookies_Button.click() 上面的代码应该返回所有按钮,并且 for 语句将循环遍历它们,查找任何读取 Accept Cookies 的按钮。

回答 2 投票 0

WebDriver等待find_elements_by_xpath

我试图弄清楚 WebDriverWait 如何与 find_elements_by_xpath 一起使用。它如何知道所有相关元素已加载,或者只是等待页面加载。 我可以理解如果...

回答 3 投票 0

机器人框架未在詹金斯上运行

我正在尝试在本地詹金斯上运行机器人框架。当我在本地运行机器人框架时,它工作得很好,但是当我尝试使用 Jenkin 运行它时,它根本不起作用并给出这个错误......

回答 3 投票 0

如何获取仅在页面中可见的webElements列表

我想获取当前出现在页面上的元素列表,因为某些内容隐藏在我不想访问的页面中。

回答 3 投票 0

无法定位元素:{"method":"link text","selector":"Sales Matrix"} SELENIUM 和 JAVA - JavascriptExecutor

我有一个带有可折叠动作的按钮: 它包含以下信息: 我有这个带有可折叠动作的按钮: 它包含以下信息: <strong data-bind="css: {'admin__collapsible-title': collapsible, title: !collapsible, '_changed': changed, '_loading': loading, '_error': error}" class="admin__collapsible-title"> <span data-bind="i18n: label">Sales Matrix</span> <!-- ko if: collapsible --><span class="admin__page-nav-item-messages"> <span class="admin__page-nav-item-message _changed"> <span class="admin__page-nav-item-message-icon"></span> <span class="admin__page-nav-item-message-tooltip" data-bind="i18n: 'Changes have been made to this section that have not been saved.'">Changes have been made to this section that have not been saved.</span> </span> <span class="admin__page-nav-item-message _error"> <span class="admin__page-nav-item-message-icon"></span> <span class="admin__page-nav-item-message-tooltip" data-bind="i18n: 'This tab contains invalid data. Please resolve this before saving.'">This tab contains invalid data. Please resolve this before saving.</span> </span> <span class="admin__page-nav-item-message-loader"> <span class="spinner"> <!-- ko repeat: 8 --><span data-repeat-index="0"></span><span data-repeat-index="1"></span><span data-repeat-index="2"></span><span data-repeat-index="3"></span><span data-repeat-index="4"></span><span data-repeat-index="5"></span><span data-repeat-index="6"></span><span data-repeat-index="7"></span><!-- /ko --> </span> </span> </span><!-- /ko --> </strong> 我尝试了很多方法来单击该按钮,但似乎没有任何效果。 我尝试过: a) driver.findElement(By.xpath("//span[contains(text(),'Sales Matrix')]")).click();. b) driver.findElement(By.xpath("//span[normalize-space()='Sales Matrix']")).click();. 我认为这是定位器问题,并且正在考虑使用一些JavascriptExecutor,但实际上不知道在这种情况下如何实现这一点。 我该怎么办? 我能够通过这样做解决这个问题: WebElement element = driver.findElement(By.xpath("//span[contains(text(),'Sales Matrix')]")); JavascriptExecutor executor = (JavascriptExecutor)driver; executor.executeScript("arguments[0].click();", element); 谢谢! 仅供参考,有不同的点击方式。 // Click using Action Actions actions = new Actions(browser); actions.click(tempWebElem).build().perform(); // Click using JS ((JavascriptExecutor) driver).executeScript("arguments[0].click();", tempWebElem); // Click using WebElement driver.findElement(tempElem).click(); // Click using Send Keys driver.findElement(tempElem).sendKeys(Keys.RETURN); 在我们的项目中,我将这些行放在嵌套的 try-catch 中,以便在遇到定位器问题时可以尝试其他方法。

回答 2 投票 0

从 chrome 85 开始,偶尔出现 Selenium Chrome WebDriver 超时

我有一些使用 Selenium 并在 Chrome 上运行的 .NET Core 自动化项目。构建在 Jenkins 管道中运行,当前在 Linux 构建代理上运行测试。 这些测试...

回答 2 投票 0

使用 Seleniumwire 的导入错误

我无法弄清楚是什么导致了错误。 Python 3.9、3.10。 回溯(最近一次调用最后一次): 文件“C:\Users\User\Desktop\S\SS est.py”,第 1 行,在 中 来自硒...

回答 3 投票 0

默认调用父构造函数?

我有来自 python page_object 文档的以下示例: 从 page_objects 导入 PageObject、PageElement 从硒导入网络驱动程序 类登录页面(页面对象): 用户名 = PageE...

回答 2 投票 0

如何在Robot Framework中编写多个条件的if语句

我在Robot Framework 中编写if 条件时遇到困难。 我想执行 运行关键字 If '${color}' == 'Red' OR '${color}' == 'Blue' OR '${color}' == 'Pink' 检查数量 我可以用这个...

回答 4 投票 0

如何在运行 Selenium 脚本时禁用 chrome 浏览器中的身份验证弹出窗口

在此处输入图像描述通过第一个 URL,我单击“登录”(如图所示),这会导致我需要在其中输入凭据的另一个 URL。但在该页面之前,我看到一个弹出窗口生成...

回答 2 投票 0

如何通过Selenium阻止chrome中的弹出窗口

我正在使用java和selenium来编写自动化测试脚本。这里目标自动化组织有一些提醒弹出窗口,所以在接受直接命令时会造成混乱...

回答 3 投票 0

使用脚本设置 Selenium Grid

设置硒网格: 我能够在命令提示符中使用以下命令设置网格(集线器和节点),然后能够启动浏览器并成功执行测试。 java -jar 选择...

回答 2 投票 0

如何使用路径、服务和选项启动驱动程序

我在我的应用程序中使用 Chrome、Firefox 和 Edge 的驱动程序,但总是遇到同样的问题。 因此,在这篇文章中,我以 Chrome 驱动程序为例减少了我的请求。 需要什么: 路径...

回答 2 投票 0

click() 在硒无头模式下不单击按钮

我使用 Chrome 驱动程序在远程服务器上以无头模式运行硒测试。以下步骤尝试单击按钮,但未单击该按钮。 下面的测试步骤尝试单击

回答 2 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.