selenium 相关问题

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

如何在global.properties文件中定义文件路径?

我有一个 global.properties 文件,必须在该属性文件中定义文件路径。 SheetPath=C:\Users\test\Automation-Scripts\DataTable.xlsx 这是绝对路径,但需要 w...

回答 3 投票 0

将元数据添加到 pytest_configure 文件中,出现内部错误 AttributeError:“Config”对象没有属性“metadata”

我已经导入了 pytest 并安装了 pytest html,我正在尝试将元数据添加到 pytest_configure 文件中,但是当我在终端中运行测试时,我没有返回内部服务器错误属性

回答 3 投票 0

将从selenium获取的cookie设置为python请求时出现“TypeError:预期字符串或类似字节的对象”

我写了一个selenium脚本来获取网站的cookie: pickle.dump(driver.get_cookies() , open("cookies.pkl","wb")) 我尝试将获取的 cookie 传递给请求 饼干=

回答 1 投票 0

unDetected_chromedriver 耗时太长

我正在使用 selenium 和 unDetected_chromedriver 从 9gag 中抓取模因。我通过打印标题来测试代码,大约需要 7 到 10 秒。我不确定这是否正常。我想要

回答 2 投票 0

想要检索给定WebElement的Xpath

使用 Selenium WebDriver,我可以获得页面中所有 Web 元素的列表。我想编写一个函数,它将返回传递元素的 XPath 字符串。 调用函数将类似于:-

回答 4 投票 0

我如何从WebElement获取xpath

我如何从WebElement获取xpath Webelement element= driver.findElement(By.xpath("//div//input[@name='q']")); 就像是 元素.getLocator(); ->> 这应该是这样的“//...

回答 4 投票 0

find_element_by_xpath() 在 Python 中使用 Selenium 显示语法错误

我尝试在Python中使用selnium连接到Twitter。 我无法使用名称或 Xpath 进行连接。 单击“检查”即可复制 xpath,然后复制特定元素的 xpath。 所有教程...

回答 3 投票 0

在类路径中找不到功能:/cucumberOptions

我正在创建一个使用 cucumber、junit 和 TestNG 的自动化项目。 我的POM文件如下: 我正在创建一个使用 cucumber、junit 和 TestNG 的自动化项目。 我的POM文件如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>main.project</groupId> <artifactId>project</artifactId> <version>0.0.1-SNAPSHOT</version> <name>project</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.3.0</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.5</version> </dependency> <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports --> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>5.0.5</version> </dependency> <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-junit</artifactId> <version>6.9.0</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java --> <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>6.9.0</version> </dependency> <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-testng</artifactId> <version>6.9.0</version> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java8</artifactId> <version>6.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> <configuration> <suiteXmlFiles> <suiteXmlFile>testng.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> <plugin> <artifactId>maven-site-plugin</artifactId> <version>3.7.1</version> </plugin> <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> <version>3.0.0</version> </plugin> </plugins> </pluginManagement> </build> </project> 我还创建了一个新的 cucumberTestNG.xml 文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"> <suite name="Suite"> <listeners> <listener class-name = "project.Listeners"/> </listeners> <test name="Validate User Login"> <classes> <class name="cucumberOptions.TestRunner"/> </classes> </test> </suite> 我的测试运行者: package cucumberOptions; import org.junit.runner.RunWith; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import io.cucumber.testng.AbstractTestNGCucumberTests; //@RunWith(Cucumber.class) @CucumberOptions( features = "src/test/java/features", glue = "stepDefinitions") public class TestRunner extends AbstractTestNGCucumberTests { } 如果我使用 TestNG Suite 运行 cucumberTestNG 文件,则会收到以下错误: Dec 09, 2020 9:16:16 PM io.cucumber.testng.TestNGCucumberOptionsProvider warnWhenJUnitCucumberOptionsAreUsed WARNING: Ignoring options provided by io.cucumber.junit.CucumberOptions on cucumberOptions.TestRunner. It is recommend to use separate runner classes for JUnit and TestNG. Dec 09, 2020 9:16:16 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get WARNING: No features found at classpath:/cucumberOptions 文件夹结构: 我的环境变量中有Java和Maven 我查看了诸如 cucumber jvm CucumberException: No features found at [] 之类的问题 并确保我的正确性用黄瓜进行测试(第一个答案),但没有运气。 如警告中所述 Dec 09, 2020 9:16:16 PM io.cucumber.testng.TestNGCucumberOptionsProvider warnWhenJUnitCucumberOptionsAreUsed WARNING: Ignoring options provided by io.cucumber.junit.CucumberOptions on cucumberOptions.TestRunner. It is recommend to use separate runner classes for JUnit and TestNG. 当前您正在导入 junit cucumber 选项。 import io.cucumber.junit.CucumberOptions; 对于 TestNg 运行器类,您需要导入 testng.CucumberOptions import io.cucumber.testng.CucumberOptions; cucumber-jvm 存储库中的示例 import io.cucumber.testng.AbstractTestNGCucumberTests; import io.cucumber.testng.CucumberOptions; import org.testng.annotations.DataProvider; @CucumberOptions(plugin = { "html:target/results.html", "message:target/results.ndjson" }) public class RunCucumberTest extends AbstractTestNGCucumberTests { @DataProvider(parallel = true) @Override public Object[][] scenarios() { return super.scenarios(); } } 我遇到了同样的问题,我通过将 Cucumber 依赖项从版本 6.11.0 降级到 1.2.6 解决了这个问题,并且我确保 cucumber-java 和 cucumber-testng 具有相同的版本,即 pom.xml 中的 1.2.6你可以看到下面: Aslo 我的 TestRunner 类如下所示,而不是扩展 AbstractTestNGCucumberTests 你应该(cucumber.api.testng.AbstractTestNGCucumberTests) 我也有类似的问题。原因是我有多个与 junit5 和 testng 相关的依赖项,所以我删除了所有与 junit5 相关的依赖项,只保留了 testng 的依赖项。然后,有了功能文件和 testng.xml 的正确路径,它就开始工作了。

回答 3 投票 0

向 Discord 提交 hcaptcha 验证码令牌以使用 selenium 创建帐户

我正在使用 python selenium 创建一个 Discord 帐户(https://discord.com/register),但它受到 hcaptcha 的保护。我有一个验证码 API (2captcha/capmonster) 来返回验证码令牌并且

回答 1 投票 0

Selenium WebDriver 异常 对远程 WebDriver 服务器的 URL xyz 的 HTTP 请求在 x 秒后超时

所以我尝试使用 C# 和 NUnit 建立一个 Selenium 测试套件。一切似乎都工作正常,直到我的测试持续时间开始超过 6 分钟。目前,任何测试都已结束...

回答 3 投票 0

有没有办法点击画布中的特定点/元素(使用javascript,jquery或selenium)

如何在画布中的特定位置应用单击? (使用坐标对我来说似乎是最合乎逻辑的,但找不到任何方法来做到这一点,欢迎任何其他想法)。请注意,我没有ac...

回答 2 投票 0

为什么Selenium占用大量内存

我想了解selenium与firefox的问题, 我使用 Firefox 版本 56.0.2,selenium3.5.1,和 geckodriver 0.19.1,服务器 ubuntu(x64) 操作系统,firefox --headless 模式 我发现当我长时间运行我的应用程序时...

回答 2 投票 0

如何在Excel中使用Selenium应用SendKeys Keys.Enter(或Keys.Return)?

我正在整理一个词汇列表并整理一个宏以从vocabulary.com 中提取信息。搜索没有按钮,所以我必须使用回车键,但 Keys.Enter 不起作用。 该...

回答 2 投票 0

尝试在selenium中获取xhr响应内容

我正在尝试使用 selenium 从 bitclout 中提取数据。我真正想要得到的是 xhr 选项卡中针对此 url (https://api.bitclout.com/api/v1/block) 加载的响应。你就会明白我的意思了

回答 1 投票 0

将 cookie 加载到 Python 请求会话时出错

我正在尝试从 selenium 导出的 cookie 将 cookie 加载到 Python 中的请求会话中,但是当我这样做时,它会返回以下错误: “‘list’对象没有属性‘extract_cookies’” 定义

回答 7 投票 0

Google Chrome 不想启动并给出错误消息

我正在尝试从我的 Linux 控制台运行 google chrome,但我遇到了这个阻止我的错误 [1210/075921.073808:错误:file_io_posix.cc(144)]打开/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_fre...

回答 1 投票 0

Selenium 无法通过 ID 定位字段

我正在尝试在网站上进行自动预订,我找到了一种选择日期和时间的方法。但是当我尝试填写表单时,Selenium 无法通过 ID 找到该元素。 网站(法语...

回答 1 投票 0

无法调用“org.openqa.selenium.WebDriver.findElement(org.openqa.selenium.By)”,因为“this.driver”为空

当我尝试在 Eclipse 中显示的 testNg 空指针异常中运行以下代码时 公共类 ImgDDChkbxRadio { WebDriver驱动程序; @测试前 公共无效启动浏览器() {

回答 10 投票 0

Python Selenium 如何单击输入类型数字递增或递减按钮

使用Python Selenium,如何单击输入类型数字的递增或递减按钮。递增和递减按钮是浏览器特定的对象,而不是 DOM 的一部分。所以我可以...

回答 2 投票 0

控制台日志/ cmd.exe 未在 chromedriver 中关闭

尝试隐藏控制台日志/cmd.exe(chromedriver.exe),但它没有隐藏/关闭.. 我试过: 选项 = webdriver.ChromeOptions() options.add_argument('--log-level=0') options.add_argument('--log...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.