How to use Click after getting text of an autogenerated time stamp



  • Using Java/Selenium and Page Objects, I have to create an item name that is auto generated using the current date and time and entered into a text field. I then have to verify that this item was created on a different page. I am storing the name (current date/time) in a string via locating the element and getting the value but at certain points this name will be a link that needs to be clicked.

    How do I make the saved String name clickable?

    Ex: Currently storing as String name = ad.name1.getAttribute("value")

    Cannot execute name.click()



  • I hope what you want to do is :

    driver.findElement(By.partialLinkText(name)).click()
    

    You already have the link text stored in the variable 'name' . So once you are in the target page , use above command .



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2