简体   繁体   中英

how can I capture web element and reuse it to for test in selenium

I need help with followings. how do i search this object from page (Node_ID="3857511") and store value in variable and reuse it for test to search object by ID.

Please help.

enter image description here

要从页面 (Node_ID="3857511") search此对象并将值存储在变量中,您可以使用以下代码行:

  • Java

     String my_id = driver.findElement(By.xpath("//div[@class='idea boundarynode nodeyellow textnode ui-droppable ui-draggable ui-draggable-handle")).getAttribute("node_id");
  • Python

     myID = driver.find_element_by_xpath("//div[@class='idea boundarynode nodeyellow textnode ui-droppable ui-draggable ui-draggable-handle").get_attribute("node_id")
  • C#

     string myId = driver.FindElement(By.XPath("//div[@class='idea boundarynode nodeyellow textnode ui-droppable ui-draggable ui-draggable-handle")).GetAttribute("node_id");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM