Hot answers tagged

10

Do you think that time is the problem here? If so try to increase the time you are providing in Thread.sleep(); and see it that works out for you. If its not the time, then did you try to find out what the problem is? Are you getting any error?


3

Major difference in TestNG and JUnit test frameworks is their scope. Junit is a unit testing framework while TestNG addresses testing at a higher level. and my recommendation is TestNG(Next Generation) Framework. Find the some references to get details about both of them- http://www.slideshare.net/ssuser220b38/junit-and-testng ...


3

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements. Annotations: In JUnit, the @BeforeClass and @AfterClass methods have to ...


2

Launching Safari browser is very easy, just you have to add safariDriver jar in your Windows Safari browser. Check after installation whether this icon is displayed or not? If Yes then it will work. Steps- Requirements: Safari Browser installed Selenium WebDriver Now we have to install SafariDriver extension with below steps. Manually install the latest ...


2

Page Factory Pattern is like an extension to Page Object Model , but Page Factory is much enhanced model. To start with, we just need to import package org.openqa.selenium.support.PageFactory "Factory class can be used to make using Page Objects simpler and easier". We use Page Factory pattern to initialize web elements which are defined in Page Objects. ...


2

I haven't tried it but there's a Chrome Extension called Selenium Page Object Generator that looks like it automates PO creation, and it supports C#. SWD Page Recorder also automates PO creation, and supports C#.


2

So what you are trying to do is have a script run on different browsers and want to register a user with a unique email address. Well, Google allows you to use single email address for such testing purposes with incremental characters appended to your ID. How this works is, You have a Gmail account say example@gmail.com. You can use this same account for ...


2

My recommendation is that you store the state of what has been used within a test. So the test would initially create a new user with a unique email. You can use some random character generation or a database sequence to make each one unique. Personally I recommend using sequences as they are more deterministic than random characters and less likely to ...


2

The reason behind the exception you have mentioned is because with your test script you are trying to locate an element that doesn't exist in the webpage you are trying to test. how will you resolve It? Well, along with the text you have provided, the console would also have given the line number in the test script where this exception occurred. I ...


2

There is another tool to record page object model. below is the link: http://seleniumrecorder.blogspot.com/


1

Check below are the various methods to scroll your page up & down. Scroll Down: import org.openqa.selenium.JavascriptExecutor; WebDriver driver = new FirefoxDriver(); JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("scroll(0, 250)"); //y value '250' can be altered Scroll up: JavascriptExecutor jse = (JavascriptExecutor)driver; ...


1

Using priority to drive order of execution is perfectly fine, but question is why do you want to execute test cases in certain order? As a general rule test case should be atomic and should not be dependent on another test cases. In such case do you worry about order of execution. I rather don't pay much attention to order of execution unless its an explicit ...


1

If you do not mind about random values, for email you can use javascript to generate valid email anytime the TestCase runs including runs in different browsers. Example (you can modify or change the script): javascript{ /*random email*/ var chars = 'abcdefghijklmnopqrstuvwxyz'; ...


1

To switch between windows there are multiple ways to do it. This is what we are using: public void switchToNewWindow(int windowNumber) { Set < String > s = driver.getWindowHandles(); Iterator < String > ite = s.iterator(); int i = 1; while (ite.hasNext() && i < 10) { String popupHandle = ...


1

adding Thread.sleep(3000) is not a good way to handle synchronization, rather use implicit wait. driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); Implicit wait allows your browser to wait until element is visible or until time set by you, whichever is earlier.


1

The silence is deafening :-) I have no personal experience with NightWatch, but I do have experience with the quirky nature of JavaScript, and because of that experience prefer Python, especially for big projects. Why you never ever reprogram working code from scratch - with history of failures cause by reprogramming from scratch. So if your company is ...


1

You can use the below code: List<String> handles = (List<String>) driver.getWindowHandles(); // Switch to the third window. driver.switchTo().window(handles .get(2)); // Close this window driver.close()


1

You may use this- Xpath1= //a[contains(.,'Create a Rediffmail account')] OR Xpath2=//a[contains(@href,'details')] OR Xpath3=.//*[@id='toprightinfo']/a[2] Or you try with other Locator types as- LinkText Check I have tried & found 1 match xpath-


1

You cannot do that with just Selenium, as @Peter-Masiar mentioned, but you can look at the Structural Similarity method. Additional link. My company has been using this method quite a lot for testing.


1

one choice by CLASS: driver.findElement(By.className("element class")) another choice: by css selector (you need to work on css selector) driver.findElement(By.cssSelector("css selector")) driver.findElement(By.cssSelector("ng-class["{\'selectedViewMenu\':SearchObj.param.View=='Videos'}]")



Only top voted, non community-wiki answers of a minimum length are eligible