New answers tagged

0

If you want to implement dynamic wait, try this: WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(elementToBeClickable(By.xpath(".//*[@id='header2']/nav/div/ul/li/a"))).click(); instead of this: Thread.sleep(3000); driver.findElement(By.xpath(".//*[@id='header2']/nav/div/ul/li/a")).click();


1

I had the same question/problem. This is how I solve it String validHtml = "some valid html"; InputStream inputStream = new ByteArrayInputStream(validHtml.getBytes(StandardCharsets.UTF_8)); Tidy tidy = new Tidy(); tidy.setXmlTags(true); tidy.parse(inputStream, null); System.out.println("errors "+tidy.getParseErrors()); ...


0

If I'm in this case, I will create a fucntion to select/unselect a checkbox then we can reuse it for all checkboxes. C# sample private void Check(IWebElement element, bool isSelect) { // get currentStatus of checkbox // if currentStatus not equal to isSelect then call click function } For a clear function, you may include it to Check() function ...


0

A renderer is used to paint each cell in the table. Code to access the component used to render the cell: TableCellRenderer renderer = table.getCellRenderer(row, column); Component c = table.prepareRenderer(renderer, row, column); System.out.println(c.getBackground()); System.out.println(c.getForeground()); System.out.println(c.getFont());


4

One way is to use a singleton class like this: public class FirefoxDriverProvider { private static FirefoxDriver instance = null; public static FirefoxDriver getInstance() { if (instance == null) { instance = ... initialize FirefoxDriver here ...; } return instance; } } In your TestNG classes, you can do ...


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

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

In your position I would look at creating a single JUnit test that loops through the csv rows and behaves accordingly based on the parameters given in each row. I assume you haven't done it like this for reportability reasons? You want to be able to get feedback on each row or something like that? It is possible to hack at the TestRunner to do something ...


0

I would assume that to run test cases in parallel, you need to have multiple instances of the same test - which is not possible if classes are static. In Agile development, when deciding which approach to use to solve a problem, good idea is try spike solution - in your example it would be before committing yourself to architecture, try one simple test ...


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'; ...


0

The solution is to use NoBlock operation (.pushNoBlock();, .pushMenuNoBlock("File|Open");) with manually set timer ComponentOperator.WaitComponentTimeout and checking for any new component that should appear in GUI: JemmyProperties.setCurrentTimeout("ComponentOperator.WaitComponentTimeout", 5000); // 5 seconds ... searchByAddressButton.pushNoBlock(); new ...


0

Your scenario is really long and include many things. Let break down it to smaller parts, example Search product Go to site Search with keyword Verify search result Compare product Go to product detail page Click "Compare this Product" button Verify something comparison page: price, quantity, ... it depends your purpose Checkout Go to product ...


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 ...


0

UI feature tests passing in Jenkins, CircleCI (or other Continuous Integration servers) that fail locally or vica-versa is not uncommon. In a nutshell they are basically due to different environments behaving differently. The environments may vary in regards to things such as: OS - your local might be a Mac, Jenkins might be Ubuntu memory type and size ...


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 ...


-1

Instead using Selenium, you can write it by C#, Java or another language. Below is the link for C#. C# sample


0

Here is my example of ComponentChooser usage: JButtonOperator flsButton = new JButtonOperator(mainFrame, new ComponentChooser() { public boolean checkComponent(Component comp) { if (comp == null) return false; else if (!(comp instanceof JButton)) return ...


0

I know about several open source tools hosted on GitHub but didn't try them yet. Just created a list for future learning. Any additions and comments are welcome. TestFX - 213* Automation (Groovy & Java) - 48* swinger (JRuby, Cucumber-based) - 47* Marathon - 31* Window Tester - 5* This list might be updated in the future. I'm maintaining it at the ...


0

The solution that works for me now is set of properties: toolkit class & attached text. Till now I tested this set of descriptors with toolkit class of JavaObject: JEllipsisTextField JRootPane Even some objects in sequence could be omitted.


0

In your BasePage.Java instead of creating a separate WebDriver object, you can use the WebDriver object of BasePage class directly by using (BasePage.driver) as below: public class LoginTC extends BasePage{ @Test public void login() { LoginPageObjects loginPage = PageFactory.initElements(BasePage.driver, LoginPageObjects.class); ...


1

The driver field in LoginTC hides the driver field from BasePage. The BasePage class fills in its own driver field, but LoginTC uses its own, which is never initialized. Solution: Remove the driver field from LoginTC, then either: Make the driver field in BasePage public or protected. Add a "getter" method (driver() or getDriver() or similar) to BasePage ...


0

If you are using Page Factory we need to initialize the Page Object: You can initialize with the help of below sample code: driver = new FirefoxDriver(); driver.get(baseUrl); Scorex_LoginTestCases loginTest = PageFactory.initElements(driver,Scorex_LoginTestCases.class); loginTest.Scorex_valid_email_password(); And please follow the conventions as method ...


1

On the Scorex_LoginTestCases (Btw, we do not use underscore in names in Java (See conventions), the objects objLogin and objHome are not initialized. On the TestBase, you should initialize them using the PageFactory's method initElements. You can see a sample here.


0

To handle CAPTCHA field in automation is extremely difficult and in some cases not possible. You can try one of the following to try and make your tests work, Ask your dev team to set up a test environment where CAPTCHA is removed from the module you are testing, so that your tests can continue running without any problem. Some CAPTCHA have a limited ...


0

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. ...


0

In very simple terms, the explanation for page objects is as follows: A separate class (per page) which lists all the objects in a page and the allowed operations that can be performed by them can be created. And whenever you need to perform any tests on that particular page in your webapp, you write the test to first import the page, and thereafter, perform ...


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

epubcheck will assess whether your file conforms to the epub standards. It doesn't care about your content or your formatting, as long as it conforms to the epub standards. An epub file mostly a static web site compressed into zip format (plus some additional metadata). So: You could unzip the content in a directory and use Selenium to examine the HTML ...


1

I haven't done this, but since epubcheck has a CLI & java library, you could incorporate the library with WebDriver & do the validation that way. The wiki has an example of how to use it as a library.


0

No. Selenium WebDriver is a tool for operating a browser by remote control. It is not a tool validating ePub files. It is conceivable that you could find a web-based tool for validating ePub files, and that you could operate that tool using Selenium WebDriver, but I would not recommend testing that way. If you need to validate an ePub file, I recommend ...


0

Yes, definitely we can take multiple screenshots. There is no affect whether the browser is in minimize or Maximize condition. Just you have to switch the new opened window & add "Take screenshot" method after each method where you have to take screenshot. Take screenshot method can work in both mode while browser is either in Minimize or Maximize ...


0

This error occurs due to using older version of cucumber. This issue was solved in cucumber version 1.2.3 Make changes in your pom.xml <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.3</version> <scope>test</scope> ...



Top 50 recent answers are included