Reputation: 125
The below is the HTML code...here i just wanna click on the cssselector(span.icon_edit ClsUpdate) in span tag..
<div class="final_textarea">
<div class="tab_lable_right">
<textarea rows="2" cols="50" id="txttab_2" readonly="readonly" class="input col_10 input_medium box_radius clscopypaste" oncopy="return false" oncut="return false" data-columnid="20" data-columnname="Member Services Link
" data-preval="ABC insurance">ABC insurance</textarea>
</div>
<span data-columnid="20" data-columnname="Member Services Link" data-preval="ABC insurance" class="icon_edit ClsUpdate"></span>
</div>
Scenario:
My Web-Driver code is;
WebElement mainMenu = driver.findElement(By.xpath("//*[@id='txttab_2']"));
mainMenu.click();
Thread.sleep(3000);
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[@class=\"icon_edit ClsUpdate\"]")));
element.click();
Error;
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for element to be clickable: By.xpath: //span[@class="icon_edit ClsUpdate"]
Build info: version: '2.44.0', revision: '76d78cf', time: '2014-10-23 20:03:00'
System info: host: 'Axxxxx-J008', ip: '10.10.6.22', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_25'
Upvotes: 1
Views: 709
Reputation: 1
//I'm assuming your selector's are correct
WebElement mainMenu = driver.findElement(By.xpath("//*[@id='txttab_2']"));
mainMenu.click();
//this bit below searches inside the text area which is what i think you need and not the whole page.
final WebElement link = mainMenu.findElement(By.xpath("//span[@class=\"icon_edit ClsUpdate\"]"));
link.click();
Upvotes: 0
Reputation: 16201
The following code should hover over textArea element using Action class then wait for the span tag to be located and perform click.
By textArea = By.cssSelector("textarea[id^='txttab']");
By spanTag = By.cssSelector("span[class='icon_edit ClsUpdate']");
WebDriverWait wait = new WebDriverWait(driver, 10);
Actions action = new Actions(driver);
WebElement element = driver.findElement(textArea);
action.moveToElement(element).perform();
WebElement span = wait.until(ExpectedConditions.visibilityOfElementLocated(spanTag));
span.click();
Upvotes: 0
Reputation: 2507
You can try out your the below xpath on this site:
//span[@class="icon_edit ClsUpdate"]
So, your code would be:
WebElement link = driver.findElement(By.xpath("//span[@class=\"icon_edit ClsUpdate\"]"));
//wait for the element to be clickable
link.click();
Upvotes: 3