I am trying Selenium Webdriver to find input element by class name. I don't have a unique id or name in my input. Programmer added unique class name " id-input-nazwa"
but i dont know how use this name. I tried it:
(By.xpath("//input[@class='component col-xs-12 ng-scope id-input-nazwa col-sm-6 mt-2']"))
It is my DOM. I need to find a yellow input and using a yellow class from the div. :
div. :
enter image description here
Induce WebDriverWait
and visibilityOfElementLocated()
and following locator strategies.
xpath :
new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[text()='Nazwa']/following::input[1]"))).sendKeys("value");
css selector
new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.id-input-nazwa input[name*='pbInput']"))).sendKeys("value");
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.