-1

A new account is created using selenium script and a message appears that "Account is created successfully : <***12345>"

After this, Account page is displayed where all the accounts are available. And newly created account (***12345) is also listed but in the middle of table somewhere. Even sorting does not bring this account at the top so that It can be picked up after sorting.

Now I need to select this account to perform further operations on it. Currently when I click the account on 'accounts' page based on x-path provided, older account can be clicked. But since new account is created during script execution only, how can I click on this account from the account table.

I am thinking of grabbing account no. from the message box and storing in a variable but not able to write a x-path which uses this variable to click on newly added account only during execution.

Please provide your input?

3
  • Welcome. It would be helpful to add images of your webpage, a link to it if you can, what your code looks like that perfoms this test/action, what does the DOM look like? – Lee Jensen Jun 10 at 17:03
  • it would be great if you can share the XPath of the old account and the one which you are trying. By reading this, I can assume it is straightforward that you just have to build the XPath with dynamic value. There is a similar question someone asked yesterday.Please search there – Subhash Bohra Jun 11 at 4:35
  • Thanks for the input. I troubleshooted this issue as below: – anurag vyas Jun 15 at 14:38
0

I am thinking of grabbing account no. from the message box and storing in a variable but not able to write a x-path which uses this variable to click on newly added account only during execution.

Psuedo-Code:

accountPage.aCreateNew.click();
var newAccountId = messageModal.divMessage.getText();
driver.findElement(By.Xpath("//a[contains(@href, '" + newAccountId + "')).click();
2
  • Thanks for the direction. I was able to sort out issue as below: – anurag vyas Jun 15 at 14:38
  • Thanks for the direction. I was able to sort out issue as below: String accountDetails = getDriver().findElement(By.xpath)).getText(); String accountNumber = myNumbers.toString(); getDriver().findElement(By.xpath("//*[normalize-space(text())='"+accountNumber+"']")).click(); – anurag vyas Jun 15 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.