Issue
Scenario: I need to append the id to the url.
What I have done : I have taken the last id from the table and stored it in a list:
Then I get the text of the id and is Stored in a String
.
List<WebElement> id = driver.findElements(By.xpath("(//table[contains(@class,'mat-table')]//tr/td[1])[last()]"));
int rowsize = id.size();
for(int i=0;i<rowsize;i++)
{
String text = id.get(i).getText();
System.out.println("Get the id:"+text);
Then I use that text and append it to the URL
String confirmationURL = "https://test-websites.net/#/email?type=confirm";
String newurl = confirmationURL+"&id=text";
= **This part iam giving the text as id ... which is
wrong and I need to enter the id which I got from the list ....**
driver.get(newurl);
So Basically the url should be like: https://test-websites.net /#/email?type=confirm&id=47474
Can someone pls give inputs on what should be done?
Solution
You can create a new list of URLS, and can use add
method to append text.
List<WebElement> id = driver.findElements(By.xpath("(//table[contains(@class,'mat-table')]//tr/td[1])[last()]"));
String confirmationURL = "https://test-websites.net/#/email?type=confirm";
List<String> newurls = new ArrayList<String>();
int rowsize = id.size();
for(int i = 0; i < rowsize; i++) {
String text = id.get(i).getText();
System.out.println("Get the id:"+text);
newurls.add(confirmationURL + "&id=" + text);
}
after successfully execution of this code, you'd have a newurls
list with URLs ending with id's from //table[contains(@class,'mat-table')]//tr/td[1])[last()]
xpath.
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.