How To Extract Data From The Following Html?
To extract the text Fiber är beställd till adressen. Tjänsterna kan du beställa när installationen är färdig. just from the 1st span only you need to induce WebDriverWait for the text to be present in the element and you can use the following solution: Imports: Line of code: Text will be: If you have no more You can use below bindings in CSS selector Edit:Solution 1:
from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.common.byimportByfrom selenium.webdriver.supportimport expected_conditions asEC
#Option 1 - text_to_be_present_in_element and CSS_SELECTORelement = WebDriverWait(driver, 20).until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, "div.infoMessageInner>p>span.ng-binding"), "Fiber är beställd till adressen"))
#Option 2 - text_to_be_present_in_element_value and CSS_SELECTORelement = WebDriverWait(driver, 20).until(EC.text_to_be_present_in_element_value((By.CSS_SELECTOR, "div.infoMessageInner>p>span.ng-binding"), "Fiber är beställd till adressen"))
#Option 3 - text_to_be_present_in_element and XPATHelement = WebDriverWait(driver, 20).until(EC.text_to_be_present_in_element((By.XPATH, "//div[@class='infoMessageInner']/p/span[@class='ng-binding']"), "Fiber är beställd till adressen"))
#Option 4 - text_to_be_present_in_element_value and XPATHelement = WebDriverWait(driver, 20).until(EC.text_to_be_present_in_element_value((By.XPATH, "//div[@class='infoMessageInner']/p/span[@class='ng-binding']"), "Fiber är beställd till adressen"))
Fiber är beställd till adressen. Tjänsterna kan du beställa när installationen är färdig.
Solution 2:
<span>
elements in html, you can just find first span element with driver.find_element_by_tag_name('span').text
Solution 3:
.ng-binding
driver.find_element_by_css_selector('.ng-binding').text
Post a Comment for "How To Extract Data From The Following Html?"