What can I use to address v-if, css selector or xpath?
div class="el-table-box" v-if="!specialAnnounce">
What can I use to address v-if, css selector or xpath?
div class="el-table-box" v-if="!specialAnnounce">
Given the HTML:
<div class="el-table-box" v-if="!specialAnnounce">
You can use either of the following locator strategies:
Using CSS_SELECTOR:
element = driver.find_element(By.CSS_SELECTOR, "div.el-table-box[v-if$='specialAnnounce']")
Using XPATH:
element = driver.find_element(By.XPATH, "//div[@class='el-table-box' and contains(@v-if, 'specialAnnounce')]")
Note : You have to add the following imports :
from selenium.webdriver.common.by import By
Check the below code, using ExplicitWait
and CSS
locator:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 20)
announcement_elements = wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div.el-table-box[v-if$='specialAnnounce']")))