Tag: selenium

maven:在此行找到多个注释:

我有一个非常简单的maven项目来运行一些selenium测试。 这是我的pom.xml : 4.0.0 ignite selenium 0.0.1-SNAPSHOT jar selenium http://maven.apache.org UTF-8 info.cukes cucumber-picocontainer 1.2.5 test info.cukes cucumber-java 1.2.4 org.seleniumhq.selenium selenium-java 3.3.1 但它抱怨: Multiple annotations found at this line: – Failure to transfer xalan:xalan:jar:2.7.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or […]

Selenium:获取元素的工具提示?

我试图从网站中的元素中提取文本。 HTML代码是这样的: ” Give it purpose—fill it with books, movies, mobiles, cameras, toys and fashion jewellery.” 以下是我的TestNG代码: package TestNG; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Action; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.Test; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; public class Tooltip { WebDriver driver; WebDriverWait wait; By stayOn=By.cssSelector(“span[class=’redir-a-button-sec-center’]”); By cart=By.cssSelector(“span[class=’nav-line-2′]”); @Test public void cart() […]

我无法在Selenium中重写Java的C#解决方案

我在C#上修改了FireFox浏览器时遇到了一些问题。 当浏览器打开并出现错误时: TypeError:给定browserName [object String]“firefox”,但我的名字是[object String]“anotherbrowser” 我认为,这是因为浏览器的名称为“anotherbrowser”而不是“firefox”的二进制代码。 所以我在Java上找到了解决方案: FirefoxOptions options = new FirefoxOptions(); options.setBinary(“Path to browser binary”); options.setCapability(“browserName”, “anotherbrowser”); options.setCapability(“marionette”, false); driver = new FirefoxDriver(options); 我测试了它,它的工作正常。 但我需要C#,所以我试着重写它: DesiredCapabilities cap = DesiredCapabilities.Firefox(); cap.SetCapability(“browserName”, “anotherbrowser”); cap.SetCapability(“firefox_binary”, @”Path to browser binary”); IWebDriver driver = new FirefoxDriver(cap); //here’s error 但是我收到了一个错误: browserNamefunction已经有一个选项。 请改用。 请帮我重写Java解决方案到C#。 我遇到了麻烦,因为在C#中没有相同的方法,比如在Java中: “options.setCapability(”“,”“);” Ps我不能使用原始的Firefox浏览器,因为它与我修改过的Firefox没有相同的优势。

使用Selenium for Java和.NET应用程序的优点/缺点是什么?

我是一个新项目的测试主管,我们从头开始重新编写一些大约12年的Web应用程序。 我们可以自由地定义流程和技术。 我的目标是使用与某些Continuous Integration服务器连接的Selenium 2(在python中)进行自动function(用于回归)测试。 目前我们正在考虑2种技术Java vs .NET(C#) 我的相当普遍的问题是:对于Java和.NET应用程序使用selenium 2有什么优点/缺点吗? 从我的(测试者)角度来看,我认为这不会对我的自动化测试产生重大影响,因为我们将从用户的角度创建它们,但也许我错了,这就是我在这个地方问它的原因。 谢谢,迈克尔

在TestNG中运行多个类

我正在尝试自动化一个场景,其中,我想一次登录到应用程序然后进行操作而无需再次重新登录。 考虑一下,我有代码在特定类的@BeforeSuite方法中登录应用程序。 public class TestNGClass1 { public static WebDriver driver; @BeforeSuite public static void setUp(){ System.setProperty(“webdriver.chrome.driver”, “D://Softwares//chromedriver.exe”); driver = new ChromeDriver(); //driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get(“https://www.myfitnesspal.com”); } @AfterSuite public static void close(){ driver.close(); } } 我在TestNGClass2中有@test方法,它基本上试图点击一些登录按钮。 public class TestNGClass2 extends TestNGClass1 { public static WebDriver driver; @Test public static void login(){ System.out.println(“Entering the searchQuery […]

无法使用selenium webdriver在Compose E-mail页面上的To(Email id)字段中发送密钥

“ To ”Buttom 无法从selenium webdriver 获取密钥 。 在输出中,它显示无法定位元素。 “To”在iframe中,我使用了I帧但是它也没用。 import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class mail { public static void main(String[] args) throws InterruptedException { System.setProperty(“webdriver.gecko.driver”, “D:\mozilla driver\geckodriver.exe”); WebDriver driver=new FirefoxDriver(); driver.get(“https://www.mail.com/int/”); driver.findElement(By.xpath(“.//*[@id=’login-button’]”)).click(); driver.findElement(By.xpath(“.//*[@id=’login-email’]”)).sendKeys(“rahulrahulxyz@mail.com”); driver.findElement(By.xpath(“.//*[@id=’login-password’]”)).sendKeys(“incredible”); driver.findElement(By.xpath(“.//*[@id=’login-form’]/button”)).click(); driver.switchTo().frame(“thirdPartyFrame_home”); driver.findElement(By.linkText(“Compose E-mail”)).click(); Thread.sleep(5000); driver.switchTo().frame(“thirdPartyFrame_mail”); // **here is error** driver.findElement(By.xpath(“.//*[@id=’idbd’]/div[2]/div[1]/div[1]/div[2]/div/div/ul/li/input”)).sendKeys(“abcde@mail.com”); } }

如何使用Sikuli或Selenium一起按 + 键

我需要按WINDOW + UpArrow 。 在第一次尝试时,我尝试过sikuli : – s1.type(Key.WIN + Key.UP); 但它只按WINDOW和UpArrow按钮, 但是分开 。 通过selenium我尝试使用Actions类,但我发现没有键可用于按下WINDOW按钮。

我得到了这个seleniumexception:在尝试使用java和Appium运行测试时尚未实现Method

我得到了这个selenium例外: org.openqa.selenium.WebDriverException : Method has not yet been implemented 在尝试使用java和Appium运行我的测试时,特别是当我尝试使用touchAction和Tap()时会出现这个错误,我会在项目中添加一些jar文件或者什么? 这个错误的起源是什么? 在这里我正在使用的jar子: 这里是appium日志 谢谢你的帮助。

是否可以在selenium中设置元素的背景颜色

我正在使用Selenium和Java,我想在屏幕上更改元素的背景颜色。 可能吗?

获取url时,HtmlUnitDriver会导致问题

我有一个使用Selenium库用Java开发的页面爬虫。 抓取工具通过一个网站启动,该网站通过Javascript 3应用程序启动,这些应用程序在弹出窗口中显示为HTML。 启动2个应用程序时,爬网程序没有问题,但在第3个爬虫程序上,爬网程序永远冻结。 我正在使用的代码类似于 public void applicationSelect() { … //obtain url by parsing tag href attributed … this.driver = new HtmlUnitDriver(BrowserVersion.INTERNET_EXPLORER_8); this.driver.seJavascriptEnabled(true); this.driver.get(url); //the code does not execute after this point for the 3rd app … } 我也试过通过以下代码点击web元素 public void applicationSelect() { … WebElement element = this.driver.findElementByLinkText(“linkText”); element.click(); //the code does not execute after […]