I am not able to locate an Element from a dropdown and it's showing NoSuchElementException is someone can...












0















On Firefox webdriver:



WebDriverWait wait4 = new WebDriverWait(driver, 15);
wait4.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div")));
//Action class to pick the value from dorp down
WebElement mnuElement = driver.findElement(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div"));

WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' and contains(text(),'17/18')]"));

Actions actionT = new Actions(driver);

actionT.moveToElement(mnuElement).clickAndHold(submnuElement).click().build().perform();


Error:




org.openqa.selenium.NoSuchElementException: Unable to locate element:
.//span[@class='ng-binding' and contains(text(),'17/18')]




Main Element focussed on the dropdown
enter image description here



subelement
enter image description here










share|improve this question





























    0















    On Firefox webdriver:



    WebDriverWait wait4 = new WebDriverWait(driver, 15);
    wait4.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div")));
    //Action class to pick the value from dorp down
    WebElement mnuElement = driver.findElement(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div"));

    WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' and contains(text(),'17/18')]"));

    Actions actionT = new Actions(driver);

    actionT.moveToElement(mnuElement).clickAndHold(submnuElement).click().build().perform();


    Error:




    org.openqa.selenium.NoSuchElementException: Unable to locate element:
    .//span[@class='ng-binding' and contains(text(),'17/18')]




    Main Element focussed on the dropdown
    enter image description here



    subelement
    enter image description here










    share|improve this question



























      0












      0








      0








      On Firefox webdriver:



      WebDriverWait wait4 = new WebDriverWait(driver, 15);
      wait4.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div")));
      //Action class to pick the value from dorp down
      WebElement mnuElement = driver.findElement(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div"));

      WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' and contains(text(),'17/18')]"));

      Actions actionT = new Actions(driver);

      actionT.moveToElement(mnuElement).clickAndHold(submnuElement).click().build().perform();


      Error:




      org.openqa.selenium.NoSuchElementException: Unable to locate element:
      .//span[@class='ng-binding' and contains(text(),'17/18')]




      Main Element focussed on the dropdown
      enter image description here



      subelement
      enter image description here










      share|improve this question
















      On Firefox webdriver:



      WebDriverWait wait4 = new WebDriverWait(driver, 15);
      wait4.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div")));
      //Action class to pick the value from dorp down
      WebElement mnuElement = driver.findElement(By.xpath(".//*[@id='introjsTicketsFilters']/gc-filters/div[3]/gc-dropdown/div/div/div"));

      WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' and contains(text(),'17/18')]"));

      Actions actionT = new Actions(driver);

      actionT.moveToElement(mnuElement).clickAndHold(submnuElement).click().build().perform();


      Error:




      org.openqa.selenium.NoSuchElementException: Unable to locate element:
      .//span[@class='ng-binding' and contains(text(),'17/18')]




      Main Element focussed on the dropdown
      enter image description here



      subelement
      enter image description here







      selenium-webdriver






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 5:59









      Guy

      18.9k72249




      18.9k72249










      asked Nov 15 '18 at 5:10









      Ritu NehraRitu Nehra

      61




      61
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You use "and" Expression in your XPATH.In AND expression, two conditions are used, both conditions should be true to find the element. It fails to find element if any one condition is false.




          I am sure that "ng-bind" class use on your html page at somewhere in
          different span tags.




          If both conditions are satisfied than it will work.



          Use OR Expression instead of AND



          OR Expression:



          In OR expression, two conditions are used, whether 1st condition OR 2nd condition should be true. It is also applicable if any one condition is true or maybe both. Means any one condition should be true to find the element.



          WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' OR contains(text(),'17/18')]"));


          If this solution works please post your HTML code.






          share|improve this answer
























          • Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

            – Ritu Nehra
            Nov 16 '18 at 5:20











          • WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

            – Ritu Nehra
            Nov 16 '18 at 5:21













          • @RituNehra That's great Please upvote and mark it as answer if it works for you.

            – Dhru 'soni
            Nov 16 '18 at 5:57











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312811%2fi-am-not-able-to-locate-an-element-from-a-dropdown-and-its-showing-nosuchelemen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You use "and" Expression in your XPATH.In AND expression, two conditions are used, both conditions should be true to find the element. It fails to find element if any one condition is false.




          I am sure that "ng-bind" class use on your html page at somewhere in
          different span tags.




          If both conditions are satisfied than it will work.



          Use OR Expression instead of AND



          OR Expression:



          In OR expression, two conditions are used, whether 1st condition OR 2nd condition should be true. It is also applicable if any one condition is true or maybe both. Means any one condition should be true to find the element.



          WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' OR contains(text(),'17/18')]"));


          If this solution works please post your HTML code.






          share|improve this answer
























          • Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

            – Ritu Nehra
            Nov 16 '18 at 5:20











          • WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

            – Ritu Nehra
            Nov 16 '18 at 5:21













          • @RituNehra That's great Please upvote and mark it as answer if it works for you.

            – Dhru 'soni
            Nov 16 '18 at 5:57
















          0














          You use "and" Expression in your XPATH.In AND expression, two conditions are used, both conditions should be true to find the element. It fails to find element if any one condition is false.




          I am sure that "ng-bind" class use on your html page at somewhere in
          different span tags.




          If both conditions are satisfied than it will work.



          Use OR Expression instead of AND



          OR Expression:



          In OR expression, two conditions are used, whether 1st condition OR 2nd condition should be true. It is also applicable if any one condition is true or maybe both. Means any one condition should be true to find the element.



          WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' OR contains(text(),'17/18')]"));


          If this solution works please post your HTML code.






          share|improve this answer
























          • Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

            – Ritu Nehra
            Nov 16 '18 at 5:20











          • WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

            – Ritu Nehra
            Nov 16 '18 at 5:21













          • @RituNehra That's great Please upvote and mark it as answer if it works for you.

            – Dhru 'soni
            Nov 16 '18 at 5:57














          0












          0








          0







          You use "and" Expression in your XPATH.In AND expression, two conditions are used, both conditions should be true to find the element. It fails to find element if any one condition is false.




          I am sure that "ng-bind" class use on your html page at somewhere in
          different span tags.




          If both conditions are satisfied than it will work.



          Use OR Expression instead of AND



          OR Expression:



          In OR expression, two conditions are used, whether 1st condition OR 2nd condition should be true. It is also applicable if any one condition is true or maybe both. Means any one condition should be true to find the element.



          WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' OR contains(text(),'17/18')]"));


          If this solution works please post your HTML code.






          share|improve this answer













          You use "and" Expression in your XPATH.In AND expression, two conditions are used, both conditions should be true to find the element. It fails to find element if any one condition is false.




          I am sure that "ng-bind" class use on your html page at somewhere in
          different span tags.




          If both conditions are satisfied than it will work.



          Use OR Expression instead of AND



          OR Expression:



          In OR expression, two conditions are used, whether 1st condition OR 2nd condition should be true. It is also applicable if any one condition is true or maybe both. Means any one condition should be true to find the element.



          WebElement submnuElement = driver.findElement(By.xpath(".//span[@class='ng-binding' OR contains(text(),'17/18')]"));


          If this solution works please post your HTML code.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 9:41









          Dhru 'soniDhru 'soni

          444317




          444317













          • Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

            – Ritu Nehra
            Nov 16 '18 at 5:20











          • WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

            – Ritu Nehra
            Nov 16 '18 at 5:21













          • @RituNehra That's great Please upvote and mark it as answer if it works for you.

            – Dhru 'soni
            Nov 16 '18 at 5:57



















          • Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

            – Ritu Nehra
            Nov 16 '18 at 5:20











          • WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

            – Ritu Nehra
            Nov 16 '18 at 5:21













          • @RituNehra That's great Please upvote and mark it as answer if it works for you.

            – Dhru 'soni
            Nov 16 '18 at 5:57

















          Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

          – Ritu Nehra
          Nov 16 '18 at 5:20





          Hi @Dhru thanks for investigating the issue i used below code and it worked for me.I got to know the Dev's has refactored that page and the new class wasn't merged.

          – Ritu Nehra
          Nov 16 '18 at 5:20













          WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

          – Ritu Nehra
          Nov 16 '18 at 5:21







          WebDriverWait wait4 = new WebDriverWait(driver, 40); wait4.until(ExpectedConditions.elementToBeClickable(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]"))); WebElement mnuElement; WebElement submnuElement; mnuElement = driver.findElement(By.xpath("//gc-dropdown//div[*[contains(text(), 'Season')]]")); mnuElement.click(); Thread.sleep(4000); submnuElement = driver.findElement(By.xpath("//gc-dropdown//*[contains(@class, 'dropdown-item')]//*[text() = '17/18']")); submnuElement.click(); Thread.sleep(3000);

          – Ritu Nehra
          Nov 16 '18 at 5:21















          @RituNehra That's great Please upvote and mark it as answer if it works for you.

          – Dhru 'soni
          Nov 16 '18 at 5:57





          @RituNehra That's great Please upvote and mark it as answer if it works for you.

          – Dhru 'soni
          Nov 16 '18 at 5:57




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312811%2fi-am-not-able-to-locate-an-element-from-a-dropdown-and-its-showing-nosuchelemen%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python