0

I have div and hyperlink like this:

<div id="food-add-actions" class="actions food_dialog fd_food_dialog_s-fndds2-f41210000">
  <div class="right">
     <a href="Javascript://" class="food-add-button add button"><span></span><span>Add to Food Log</span></a>
    <a href="Javascript://" class="edit button"><span></span><span>Edit</span></a>
  </div>
</div>

how can i click on this Edit hyperlink?

i tried below but it did not worked for me

driver.findElement(By.className("edit button")).click(); 
Dan
  • 2,086
  • 11
  • 71
  • 137
  • I think this question answers your question: http://stackoverflow.com/questions/16089492/selenium-webdriver-w-java-locating-elements-with-multiple-class-names-with-one – Stilltorik Jun 10 '14 at 07:41

1 Answers1

1

The problem you actually have is that you have a space in your By.className.

There is a question with a similar problem here.

webdriver classname with space using java

You should be able to select it with a By.css selector, such as.

By.css('.right a.button') 
Community
  • 1
  • 1
Woodham
  • 4,053
  • 2
  • 20
  • 15