I am not able to figure out how to click the link within div***
Below is my page resource, xpath, css & my failure attempts. With each of the attempts, I received org.openqa.selenium.NoSuchElementException: no such element...
Help?
<form id="SearchAllCampaignsForm" action="/as/update.do" method="post" name="SearchAll">
<style>
<script>
<div class="body-content">
<input type="hidden" value="" name="campCookie">
<div id="container" class="Coptions">
<div class="containcamps">
<div id="dwrapper" class="dTables_wrapper" role="grid">
<div class="owrapper">
<div class="refresh">
<div class="addRow">
***<div class="AddContentBTN" title="Add New" rel="createCampaign">Add New</div>***
</div>
</form>
My attempts:
@Test
public void addCamp(){
//WebElement link = driver.findElement(By.linkText("Add New"))
//driver.findElement(By.xpath("//div[@class='AddContentBTN']/rel[text()='createCampaign']")).click();
//driver.findElement(By.xpath("//a[@title = 'Add New']")).click();
//Actions builder = new Actions(driver);
//builder.moveToElement(addCamp).click().perform();
//driver.findElement(By.cssSelector("div.wrapper div.row-fluid form#SearchAllCampaignsForm div.body-content div.container div#dataTable_wrapper.dataTables_wrapper div.optionswrapper div.addRow div.AddContentBTN")).click();
}
xPath and CSS:
/html/body/div[3]/div/form/div/div[2]/div/div/div[2]/div
html body div.wrapper div.row-fluid form#SearchAllCampaignsForm div.body-content div.container div#dataTable_wrapper.dataTables_wrapper div.optionswrapper div.addRow div.AddContentBTN
Use:
driver.findElement(By.className("AddContentBTN")).click();
In case you don't know, documentation for Selenium's "By" class can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With