It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Selenium WebElement.click() does not actually click element underneath "issuetype-suggestions"

Hi all,

We're testing out some custom JavaScript that changes the Description field when the Issue Type field is changed in the Create Issue dialog. I basically put listeners on "issuetype-field", "issuetype-suggestions", and "issuetype-single-select".

If I manually open a browser and click on Issue Type and change the Issue Type value myself by hand, the Create Issue dialog works as expected...and my JavaScript works without issue.

I then wrote some Selenium2 / WebDriver code to driver.findElement() WebElement objects and then execute the .click() method on those WebElement objects.

If I Debug execute the Selenium2 / WebDriver code within IntelliJ IDEA and manually step my way through the Selenium2 / WebDriver code, the Create Issue dialog works as expected...and my JavaScript works without issue.

However, if I Run execute the Selenium2 / WebDriver code within IntelliJ IDEA, the Create Issue dialog seems to stop working as expected...and so my JavaScript fails.

Here is my Selenium2 / WebDriver code:

  • To change the issue type, I first need to click on the Issue Type drop-down (it has the id "issuetype-suggestions"):
    • Code:

      By byObject = By.id("issuetype-single-select");
      driver.findElement(byObject).click();
    • Expected: the "issuetype-suggestions" section appears underneath
    • Actual (whether Debug or Run in IntelliJ IDEA) : matches Expected (yay!)
  • I next need to select an entry within the "issuetype-suggestions" section.  Unfortunately, the entries don't have id attributes; instead, they have titles.  Hence:
    • Code: 

      By byObject = By.cssSelector("div#issuetype-sugestions a[title=Task]");
      driver.findElement(byObject).click();
    • Expected: 
      • the "issuetype-suggestions" section disappears
      • the Issue Type changes to Task
      • the Description updates to whatever the JavaScript is supposed to do
    • Actual (if stepping through code in Debug mode): matches Expected (yay!)
    • Actual (if instead in Run mode):
      • the "issuetype-suggestions" section disappears
      • the Issue Type does not change!!!

I've tried all kinds of things to remedy this in Run mode under the assumption that maybe there's some code which need to load behind the scenes before I execute the .click() method on the Task entry within "issuetype-suggestions" – thus a pause of some sort is necessary:

  • WebDriverWait.until() with an ExpectedConditions clause that checks for both the "issuetype-suggestions" and Task title exist
  • Thread.sleep(5000)
  • using a JavascriptExecutor to check document.readyState == "complete"

None of those work.  Help?????

 

5 answers

1 accepted

0 votes
Answer accepted

I figured out one workaround, but it's a hack, so hoping somebody else will know a better way than this...

Example code to select "Bug" from the list of issue types which appear in the "issuetype-suggestions" div:

jQuery('div#issuetype-suggestions .active').removeClass('active');
jQuery('div#issuetype-suggestions a[title="Bug"]').parent().addClass('active');
jQuery('div#issuetype-suggestions a[title="Bug"]').click();

I've also tried: * having Selenium2 / WebDriver click on the <img> node instead of the <a>: {code}By byObject = By.cssSelector("div#issuetype-sugestions a[title=Task] img");{code}, and * having Selenium2 / WebDriver click on the <li> node which is the parent of the <a> node: {code}By byObject = By.cssSelector("div#issuetype-sugestions a[title=Task]").findElement(By.xpath("..")); Still no luck...

Additional things I've tried: * having a JavascriptExecutor click the <a> with JS * having a JavascriptExecutor mouseover the <a> and then click it with JS * modifying the class attribute for the <a> to add the additional class "active" * physically moving the mouse to hover over the <a> which is going to be clicked during a brief Thread.sleep pause In all of these cases as well as the cases described above, the click() being sent by Selenium or its JavascriptExecutor is not activating the JS JIRA uses to actually change the Issue Type field to the Issue Type selected from the drop-down. There's got to be some action/event I can generate in Selenium WebDriver directly or via a JavascriptExecutor that will properly tell JIRA to change the Issue Type, but I haven't found it. So for now, I insert a 10-second delay after "issuetype-suggestions" appears...and then manually click the Issue Type with my mouse. Somebody please help me.

you need something like //span[text()="Epic"]

I have similar issue. Looking for a solution. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

How InVision centralized their tools and scaled their remote team with Atlassian and Slack

Hi Atlassian Community, We recently published a case study that we thought you might be interested in. Learn about how InVision built their fully remote company’s culture using Atlassian and Slack ...

392 views 1 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you