0

Apologies for this;

  • Event Triggers
  • Photos
  • Push Notifications
  • How can I Click on Event triggers for example using Selenium Java?

    I've tried this code:

    By.xpath("//button[contains(text(),'Event triggers')]"); By.xpath("//button[contains(text(),'Submit')]");

    I tried this as well:

    WebElement Box= driver.findElement(By.tagName("Event triggers")); Box.submit();

    Neither of these worked...

    Thank you

    3
    • Add your code and the html Commented Dec 31, 2015 at 19:53
    • Apologies for this; <ul class="dropdown-menu"> <li><a onclick="windowOpen(&quot;./controller.html&quot;);" href="javascript:void(0);">Event Triggers</a></li> <li><a onclick="windowOpen(&quot;./ti_tile_photos.html&quot;);" href="javascript:void(0);">Photos</a></li> <li><a onclick="windowOpen(&quot;./ti_notify_controller.html&quot;);" href="javascript:void(0);">Push Notifications</a></li></ul> How can I Click on Event triggers for example using Selenium Java? I've tried this code: Commented Jan 1, 2016 at 16:14
    • Future reference. There is an "edit" link under your question. Please add additional code using that instead of the comments. The formatting will also be better that way. Commented Jan 1, 2016 at 23:31

    4 Answers 4

    1

    Try to using this:

    By.xpath("//a[contains(text(),'Event triggers')]");  
    

    instead of

    By.xpath("//button[contains(text(),'Event triggers')]"); 
    
    Sign up to request clarification or add additional context in comments.

    1 Comment

    Maybe you have iframe at your page? So you should switch into it
    0

    Based on the page source mentioned in the comment I think Event Triggers is not a button but an tag which essentially makes it a link. As you know the text of the link you are trying to click you can always use:

    driver.findElement(By.linkText("Event Triggers"));
    

    to get Event Triggers web element.

    Using xpath should be avoided due to slow performance.

    Comments

    0

    Well, if button doesnt have any id , you can try to write dynamic xpath by using "class name" and "type" (there are plenty of examples , you can learn easily how to create your xpath) , or easiest way, use firebug to locate element that you want to click and copy exact Xpath via firebug. And then click.

    Comments

    0

    The correct answer is:

    By.xpath("//button[contains(text(),'Event triggers')]").click(); 
    

    You were missing that click action.

    Comments

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.