This error message...
javascript error: a.tagName.toUpperCase is not a function error
...implies that the WebDriver instance attempted to invoke click()
on the desired element even before the element was completely rendered with in the DOM Tree.
The desired element is a Angular element. So to click()
on the element you need to induce WebDriverWait for the elementToBeClickable()
and you can use either of the following Locator Strategies:
id
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.id("addTagBtn"))).click();
cssSelector
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("td > button#addTagBtn"))).click();
xpath
:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//td/button[@id='addTagBtn' and text()='Add']"))).click();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…