Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
8

Well, first I would ask these questions: Do you really need to write Selenium test for all of these 500 pages? Do your developers write enough and good Unit tests? I assume it is a Single Page Application and for sure there are so many common components between these 500 pages i.e they are not 500 unique pages with completely different behaviours and ...


5

THINK BIG; We are going to automate everything! I am so excited! act small; Automate a single user flow. (Not login, but a real end-to-end behaviour, login might be part of this.) Fail fast; Struggle... Learn rapidly; Retrospect, inspect and adapt, decide on the next experiment and goto act small. I love simple PageObjects as pattern. Not as a "framework". ...


4

Just be yourself. They asked you to the final round, so they see potential in you. Swamping yourself with more topics and information might overwhelm you more than it benefits. The interviewers will look at you someone with 2 years of experience, not a guru/expert/god/know-it-all. Be honest, and saying I don't know is an good option to most questions. I ...


4

Yes, you can get values in form of String after that you can use them as you want. like this - String price = driver.findElement(By.xpath("your-xpth-of-selected-value")).getText(); Now this string value you can use as you need.


4

Comments explain the flow WebElement baseCard = driver.findElement(By.id("00automation")); // Finding the base of the DOM tree where the price tag will be List<WebElement> priceTags = baseCard.findElements(By.cssSelector(".card-price-tag")); // Find all price tags elements Integer sumOfPriceTags = Arrays.stream(priceTags) // For each price tag ...


3

Locate all checkboxes i.e.: List<WebElements> checkboxes = driver.findElements(By...) Now, for a 0-based list, the last element will be checkboxes.size()-1, so what we want to do is: if (checkboxes.size() > 0) { if (checkboxes.size() > 1) { checkboxes.get(checkboxes.size() - 2).click(); } else { //either ...


3

I believe you are missing out on the asterisk or the tag details, //* selects all elements in a document, regardless of name, or you could provide the tag name (input, span, table, etc). Try this code: WebElement radio= driver.findElement(By.xpath("//*[@id='mydiv']/form/div[1]/div[3]/label")); or WebElement radio= driver.findElement(By.xpath("//...


3

Note : I am giving my suggestion in Answer as I do not have sufficient reputation to be able to comment. First do not use thread sleep. Second put some implicit or explicit wait between your element finding and if condition statements.


3

Then I removed the two '\' before and after 30..then it shows an error like "The left-hand side of an assignment must be a variable"..Guys how can I resolve this? You cannot remove the two '\' because that are escape characters for the double quotes. When you remove the backslash you are creating two strings instead of one. String one will consist of "/...


3

You want to iterate over the rows of the table and verify if the text you are looking for is present. Once you locate the 'table' element you can do something like this in Java: public boolean isRegistered(String patientID) { for(WebElement row : table.findElements(By.tagName("tr"))) { if(row.getText().contains(patientID)) { return ...


3

This is one of my Page Objects. It works perfectly fine. public class MyHomePage { IWebDriver driver = null; [FindsBy(How = How.LinkText, Using = "Home"), CacheLookup] public IWebElement lnkHomeTab { get; set; } [FindsBy(How = How.TagName, Using = "Title"), CacheLookup] public IWebElement pageTitle { get; set; } public MyHomePage(...


3

Do you really want to test that the text Welcome is there? You say the identifiers are dynamic. In these situations, I always suggest to talk to the developers and make it better testable. Preferably developers and testers write and maintain the end-to-end tests together. Let them feel your pain. Now when in application developer change welcome to ...


2

If I understand correctly - You want to check if some particular WebElement is missing. While doing so you get a NoSuchElementException. The solution here will be to create a function that returns a boolean value if an element is present. Something like this: public boolean isPresent(By locator) { try { webDriver.findElement(locator); ...


2

Normally "upload button" is a HTML input of type file which looks like: <input type="file" ...... > So you need to verify whether at least 1 input of type file is present at the page. It can be done using the following XPath selector: //input[@type='file'] Example code (Python) file_upload_elements = driver.find_elements_by_xpath("//input[@type='...


2

There are a few different ways to achieve that depending on how you prefer to do things: As another person has commented you don't appear to need those int declarations, so can just use the .size() call. //Assert false that one equals the other Assert.assertFalse(preRoutlList.size()==aftRoutlList.size()); //Assert True that one doesn't equal the other ...


2

From Automation point of view following things are important: Logic OOPs concept Any language hands-on From Manual testing point of view following things are important: Basic understanding of testing terminologies Development cycle & Testing cycle Bug Reporting Testing skills From Behavioral point of view following things are important: Attitude ...


1

As a simple answer to your question: Page Objects scale well. And more on the guidance side of things... Should you be testing 500 variations on the same pages using 500 unique page objects? No, probably not. A set of pages that allow tests to check what features are enabled on the page at a given time would be a more sensible way to handle this. E.g. ...


1

According to the Selenium documentation, this constructor for WebDriverWait requires a long as second argument - the timeOutInSeconds. In Java, when NaN is used in arithmetic operations, the behavior is undefined. You simply need to use some timeout value instead of NaN when creating the WebDriverWait object.


1

You should handle pre and post setup for tests using Automation only whenever possible. You can create your code in such a way that if pre-condition script fails, none of the tests run. And for post-setup you can go with two approaches: Verify and check whether it is actually worked using code or by querying into db, if it is not worked then create new ...


1

It seems that another element is located and clicked, thus the log out. Try cssSelector: By.cssSelector("a[ui-sref='about']") I would suggest to test it in chrome devtools console like this: $$("a[ui-sref="about]") This is equivalent of document.querySelectAll so if it returns more then one element the locator is still not valid and you will have to be ...


1

Assuming that the "Value" is your attribute name and it "manual" is unique for this attribute across the page. You can use the below line to identify the element driver.findElement(By.xpath("//*[@value='manual']")) Hope it helped


1

1 - Read data from JSON Google has a very good Java library to parse JSON in a structured way: GSON The types you would use the most are JSONObject and JSONElement. 2 - Use the data in a test I would suggest having in your dataprovide only the name of the JSON file. In the test, you can call a factory that would read the JSON file and generate a POJO ...


1

In my opinion, there is no such thing as I can not use any locator here. An (assumed) upload button is part of the DOM and can be located in some way. Maybe the button is always in the same place, so you can check if By.css(".container button") is present. Maybe you can ask the devs to provide a better locator. Or you could count the visible buttons on the ...


1

Under Linux your home-dir is /home/username/ So from your screenshot I would expect the path to be: /home/username/.config/google-chrome/Default/Extensions/extensions-id Each directory in your screenshot is an extension. You could copy the extension to a path you do know. Just copy the directory with the right ID. You can find the ID's in the Chrome ...


1

Hope this help you- Your property file-(db.properties) path=//*[@class='ng-scope'] area=//*[@placeholder='Stop Name'] Now in your java class- String pathValue= props.getProperty("path"); String areaValue= props.getProperty("area"); for (int z = 0; z < rows.size(); z++) { rows.get(z).findElement(By.xpath(pathValue+"[" + (z + 1) + "]"+areaValue))...


1

The page object model is a design pattern that describes the best approach for modeling a test automation framework when it comes to web automation. The @FindBy() annotation is just a shortcut provided to developers by the PageFactory class. Use of the @FindBy() annotation is not mandatory for you to use the page object principles. You can still model your ...


1

You are probably using a wrong Java version or a old Selenium or a combination. Update everything to the latest versions.


1

Test case does not fail because it does not include any assertions. As mentioned by @Upkar Singh in the comment - your login test data is not valid, therefore page is showing some kind of error saying that login did not succeed. If you want the test case to fail, you need to assert that some condition is met (i.e. that some kind of homepage is shown). I do ...


1

This does not work, you cannot click a link that loads another page. Then go back and expect the earlier found elements to still be there in memory. getelement.get(i).click(); driver.navigate().back(); You need to again find the elements after back. Changed your example code a bit to retrieve the elements again in the loop. By path = By....


1

Handling pop-up is somewhat hard in with Selenium, mainly because there are three types of popups. JavaScript Alerts The simplest browser dialogs are JavaScript alerts. They have a special API to access their data because they are not part of the DOM. driver.switchTo().alert().getText(); Read more at https://www.guru99.com/alert-popup-handling-selenium....


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