Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

selenium lfor loops

List <WebElement> listofItems = wd.findElements(By.xpath("//*[starts-with(@id,'result_')]//div//div[1]//div//a//img"));
WebDriverWait wait = new WebDriverWait(wd, 20); //Wait time of 20 seconds

for (int i=1; i<=listofItems.size(); i++)
{ 
    /*Getting the list of items again so that when the page is
     navigated back to, then the list of items will be refreshed
     again */ 
    listofItems = wd.findElements(By.xpath("//*[starts-with(@id,'result_')]//div//div[1]//div//a//img"));

    //Waiting for the element to be visible
    //Used (i-1) because the list's item start with 0th index, like in an array
    wait.until(ExpectedConditions.visibilityOf(listofItems.get(i-1)));

    //Clicking on the first element 
    listofItems.get(i-1).click();
    wd.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    System.out.print(i + " element clicked	--");
    System.out.println("pass");
    wd.navigate().back(); 
}
Comment

PREVIOUS NEXT
Code Example
Swift :: how to declare populated dictionary in swift 
Swift :: Alamofire upload multiple image with parameters swift 5 site:stackoverflow.com 
Swift :: How to load Google map styling from json file for ios swift? 
Swift :: swift optionals 
Swift :: jsonserialization swift 
Swift :: how to unwrap arrays with optional value in swift 
Swift :: caseiterable swift 
Swift :: AMAZONCONNECT 
Swift :: Swift Modify the Elements of an Array 
Swift :: How to make dart typing stricter 
Swift :: Swift Nested for Loop 
Swift :: how to know when text changed textfield swiftui 
Swift :: how to delete from list tvos swiftui coredata 
Ruby :: rails undo scaffold 
Ruby :: command to run all rspec tests 
Ruby :: rails get current database name 
Ruby :: hello world in ruby 
Ruby :: ruby iterate over array 
Ruby :: rails migration update column default value 
Ruby :: rails string to date 
Ruby :: rails g migration add column array 
Ruby :: how to link to with font awesome rails 
Ruby :: ruby array unshift 
Ruby :: ruby debugger 
Ruby :: rails parse boolean 
Ruby :: ruby open file and append 
Ruby :: validations rails integer suprior to 0 
Ruby :: ruby random number between 
Ruby :: rails duplicate record 
Ruby :: map each with index 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =