-1

Need help in extracting the case id, would be great help

    <div class="note note-info"><h4 id="note-label-CreateCaseUploadDoc:Display_Process_Combination1:RequestID" class="note-title">A new request is created successfully</h4><p id="
    ">412312513</p></div></div>

Need to extract 412312513 out of this

prit
  • 41
  • 8

1 Answers1

2

You can use following-sibling to get text node value from p tag as follow:

//*[@class="note-title"]/following-sibling::p

OR

Using css selector

.note.note-info h4 + p

Example with selenium

txt = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, '//*[@class="note-title"]/following-sibling::p'))).text

OR selenium with css selector

txt = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, '.note.note-info h4 + p'))).text

#imports

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Md. Fazlul Hoque
  • 15,806
  • 5
  • 12
  • 32
  • i tried this but not working `String text = waitUntilElementVisibleAndFind(By.id("note-text-CreateCaseUploadDoc:Display_Process_Combination1:RequestID")).getText();` – prit May 12 '22 at 17:25
  • @ prit please try to apply the above expressions .. You din't use none of them – F.Hoque 9 hours a – Md. Fazlul Hoque May 13 '22 at 02:50
  • worked with `(By.xpath("//*[@class='note-title']/following-sibling::p")).getText();` thanks – prit May 13 '22 at 04:42