page-factory

“StaleElementReferenceException” in Selenium for a List<WebElement>

喜欢而已 提交于 2020-01-06 08:19:06
问题 Please refer the below code, this code will fetch all the orderID from findtable method and it passes all of the orderID to clickonIndividualOrderID method so the cursor moves to each orderid and it clicks on it, a new page will come and it fetch the status and clicks on done and it comes back to old page now if we try to select next orderID, it will throw the exeception Could you please suggest some approaches to resolve this issue Thanks in advance List<WebElement> orderID = new ArrayList

StaleElementReference Exception in PageFactory

瘦欲@ 提交于 2019-12-24 10:32:01
问题 I am trying to learn the PageFactory model. I understood the fact that when we do a initElements , the WebElements are located. Say for example, I click on a webelement and because of which there is a change in one of the other webelements in DOM. Now, obviously I would get a StaleElementReferenceException here. How would I resolve this issue? Should I find that specific WebElement again knowing the fact that there can be a change in the WebElement's properties in the DOM? or is there an

How to build a method to iterate through WebElements and return the one that is displayed using Selenium & Java?

若如初见. 提交于 2019-12-20 07:23:28
问题 So, the page is filled with a lot of similar properties like these two elements below. Examples: <button id="exibe_codigo_de_barras_210888-1" data-context="minhas-contas_conta_codigo-barras_btn-ver-codigo-barras-colapse" font-size="0.875rem" width="100%" class="styled__Button-sc-6mz6kj-0 gMrMBo" style="" xpath="1">VER CÓDIGO DE BARRAS <span class="sc-1o2smz3-2 dAGdGd styled__Arrow-tuh5ii-0 iYDeiw"><svg width="12px" height="8px" viewBox="0 0 12 8" version="1.1" xmlns="http://www.w3.org/2000

How to add explicit wait in PageFactory in PageObjectModel?

橙三吉。 提交于 2019-12-17 07:54:21
问题 I have added hardcode wait thread.sleep() in my below code. How to use explicit wait. I want to wait till "username" WebElement appear. My program is working perfectly. I have already written testcases. package com.pol.zoho.PageObjects; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.WebDriverWait; public class ZohoLoginPage { WebDriver

How to wait for invisibility of an element through PageFactory using Selenium and Java

て烟熏妆下的殇ゞ 提交于 2019-12-12 19:25:32
问题 Is there a way to wait for an element not present in Selenium using PageFactory annotations? When using: @FindBy(css= '#loading-content') WebElement pleaseWait; to locate the element, and then: wait.until(ExpectedConditions.invisibilityOfElementLocated(pleaseWait)); I would get: org.opeqa.selenium.WebElement cannot be converted to org.openqa.selenium.By I am able to do what I need by using: wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector('loading-content'))); However

How to use testng tag for smoke, regression tests

此生再无相见时 提交于 2019-12-08 13:42:57
问题 I have several test methods and i need to select some of them as smoke tests and others regression tests. How can i make a condition/dependency in Testng selenium, So smoke tests will run first as a group. And i can set up different Bamboo job for regression tests and those will be running only if smoke test group passed. Here's my tests are: @Test(priority=1) public void test_1(){ ----} @Test(priority=2) public void test_2(){ ----} @Test(priority=3) public void test_3(){ ----} @Test(priority

How to implement AjaxElementLocatorFactory through Selenium and Page Factory?

﹥>﹥吖頭↗ 提交于 2019-12-08 01:57:46
问题 I've used Pagefactory to set up all of my pages in Selenium. The thing is the test are dynamic in that some elements only exist in some of the test. From m understanding AjaxElementFactory works like this: PageFactory.initElements(new AjaxElementLocatorFactory(driver,5), this); @FindBy(id="ctl00_DefaultContent_RbIndividual") WebElement OwnershipIndividual; public void sendString(String stuff){ OwnershipIndividual.sendKeys(stuff); } But if the element OwnershipIndividual is not located in 5

Selenium @FindBy vs driver.findElement()

落爺英雄遲暮 提交于 2019-11-28 17:31:29
Why should I use @FindBy vs driver.findElement() ? @FindBy forces me to move all my variables to a class level (when most of them only need to be at the method level). The only thing it seems to buy me is I can call PageFactory.initElements() , which handles lazy initialization for me. What am I missing? Roughly speaking, @FindBy is just an alternate way of finding elements (the "usual way" being driver.findElement() as you said). The big advantage of that annotation is not itself, though. It is better used to support the PageObject pattern . In a few words, the PageObject pattern tells you to