Tag: selenium webdriver

如果其他测试失败,我可以跳过Junit测试吗?

我正在使用Junit与Seleniun WebDriver一起运行测试。 我正在尝试将我的测试分解为function区域,以便更好地报告错误。 我已经创建了测试页面加载/移动文档到其他工作流程的测试。 如果页面加载测试失败,或者工作流程移动失败,我想跳过后续页面/工作流程测试。 如果测试A失败,我怎么能跳过类中的其余测试或在B类中运行测试? 注意:我意识到我所问的是“ UNIT TESTS的不良实践*。但是,我实际上正在使用Junit进行集成和/或自动化测试。(根据您的定义。)我已经找到了@Suite.SuiteClasses和@FixMethodOrder订购我的测试类和测试方法。我正在尝试命令它们在逻辑上运行,测试页面加载,首先,然后将页面的每个function作为单独的测试。一些function,移动信息到其他页面,意味着其他课程。我的课程中有一个可能需要花费半小时才能完成。如果请求前测试失败,我想简短地进行“依赖”测试,以获得我的结果/报告越早越好。

线程“main”中的exceptionorg.openqa.selenium.NoSuchElementException:无法找到element:// *

我不得不重新测试xpath ,以前它工作正常,但现在它给了我一个错误。 我尝试过不同的定位器,比如id , name 。 但仍然得到相同的错误。 package staging; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class login { public static void main (String[]args){ System.setProperty(“webdriver.gecko.driver”,”C:\\Program Files\\geckodriver.exe”); WebDriver driver = new FirefoxDriver(); //opening the browser driver.get(“https://staging.keela.co/login”); //logging driver.findElement(By.xpath(“//*[@id=’login-email’]”)).sendKeys(“bandanakeela@yopmail.com”); driver.findElement(By.xpath(“//*[@id=’login-password’]”)).sendKeys(“keela”); driver.findElement(By.xpath(“//*[@id=’login-form’]/div[3]/div/button”)).click(); } }

未知错误:调用函数结果缺少’值’Appium Hybrid App

在向某些字段发送密钥时我有问题 driver.findElement(By.xpath(“//*[@id=\”login-main\”]/a”)).click(); Thread.sleep(1000); driver.findElement(By.xpath(“/html/body/div[2]/ion-nav-view/ion-view/login-popup/ion-pane/ion-content/div/form/label[2]/input”)).sendKeys(“Example”); 我将上下文设置为“driver.context(”WEBVIEW _ ********“);”,我可以单击应用程序中的按钮,但是无法将键放入字段中,它会在第一次发生,上周它正在工作。 错误是: Exception in thread “main” org.openqa.selenium.WebDriverException: unknown error: call function result missing ‘value’ (Session info: chrome=65.0.3325.109) (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information) 我尝试在CMD中使用“npm install -g chromedriver”更新chromeDriver,但chromeDriver没有更新到2.36这是最新版本。 我查了另外一个问题,他们有同样的问题,但我认为问题是我无法更新chromeDriver

Selenium Web驱动程序:findElement(By.name …和无头浏览器

我正在尝试遵循Selenium Webdrive教程 http://www.toolsqa.com/selenium-webdriver/headless-browser-testing-selenium-webdriver/ 有一个简单的测试,这里是你的步骤: 打开网页http://google.com 获取页面标题。 搜索’Selenium’ 再次检查页面标题。 从类代码示例开始,这里是您的代码 package headlessBrowser; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.htmlunit.HtmlUnitDriver; public class TestOne { public static void main(String[] args) { // Declaring and initialising the HtmlUnitWebDriver HtmlUnitDriver unitDriver = new HtmlUnitDriver(); // open google.com webpage unitDriver.get(“http://google.com”); System.out.println(“Title of the page is -> ” + unitDriver.getTitle()); // find the […]

在Selenium Webdriver中,在性能Linktext或css方面哪个更好?

在Selenium ,最好使用Locator ID定位元素。 最小的定位器是XPath (如果我错了,请纠正我)。 那么一个人应该使用Locators来确定element优先级或顺序是什么?

Chrome参数不起作用

谁知道为什么chrome参数不起作用? import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; public class testowa { public static void main(String[] args) throws InterruptedException { DesiredCapabilities capability = DesiredCapabilities.chrome(); capability.setCapability(“chrome.args”, Arrays.asList(“–disable-web-security”, “–start-maximized”)); WebDriver driver = null; try { URL hub_url = new URL(“http://192.168.56.101:4444/wd/hub”); driver = new RemoteWebDriver(hub_url, capability); } catch (MalformedURLException e) { e.printStackTrace(); } […]

如何在网页中的特定div中垂直向下滚动

我搜索了所有的论坛,但我没有得到正确的答案。 我要测试的网页下面隐藏了一个链接,我试图通过使用xpath或元素的ID属性搜索它来手动找到它,但是当我运行Web驱动程序脚本时,我无法找到它。 即使它没有在该元素上给出任何错误,我在下一个命令/行上收到错误。 我从论坛中找到了以下代码,这是滚动整个页面。 我不想这样,我想在屏幕截图中垂直向下滚动特定div区域。 JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript(“ctl00_Menu1_scrollDiv.scrollBy(0,250)”, “”); div id for this is “ctl00_Menu1_scrollDiv” Element id: ctl00_Menu1_DlMenu_ctl09_LnkMenuname 请帮我解决这个问题。 提前致谢。 帮助将不胜感激。

如何在selenium上传多个文件?

我正在尝试使用以下代码: – driver.findElement(By.xpath(“.//*[@id=’attach0′]”)).sendKeys(“first path”+”\n”+”second path””+”\n”third path”); 我没有得到结果 请帮我!

Selenium WebDriver – Java – 单击按钮

我正在尝试点击一些按钮,我正在使用twitch上的Follow按钮作为示例。 我使用Selenium IDE尝试获取按钮的xpath。 我得到的xpath是: //span[@id=’ember637′]/a/span 如果我去FireFox并为按钮复制唯一选择器我得到: .js-follow > span:nth-child(1) 我已经在java程序中尝试过它们并且它们不起作用。 当我使用//span[.. xpath时,我收到以下错误: “Unable to locate a node using //span[@id=’ember637′]/a/span” 编辑: 带有我想点击的按钮的网站示例(“关注”按钮): http : //www.twitch.tv/mradder89/profile/ 我正在使用的Selenium jar文件是“selenium-server-standalone-2.35.0.jar” 我得到的错误是 “Exception in thread “main” org.openqa.selenium.NoSuchElementException: Unable to locate a node using //span[@id=’ember637′]/a/span” 编辑2: 我下载了PhantomJSDriver exe文件(phantomjs.exe)并试用了它。 它不起作用…我没有像以前那样得到错误消息(“无法找到节点…”错误)。 这是代码: http : //pastebin.com/GzvubMZr

如何通过selenium-webdriver和Java使用java鼠标hover

在尝试自动化门户网站http://demo.nopcommerce.com/时 ,无法选择鼠标hover在“Electornics”菜单上并选择“相机和照片”子菜单。 使用下面的脚本也是如此。 WebElement electronic_Pdts = driver.findElement(By.xpath(“//*[@class=’title’]//*[@title=’Show products in category Electronics’]”)); action.moveToElement(electronic_Pdts).build().perform(); driver.findElement(By.xpath(“//*[@src=’http://sofzh.miximages.com/java/0000006_camera-photo_450.jpg’]”)).click();