2

Trying to click the button in the web application. I am opening the below page in chrome the page is opening but trying to click the button inside the page but it is not possible.

package example;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class Example {
    public static void main(String[] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver",
                "E:/chromedriver_win32/chromedriver.exe");
        WebDriver driver = new ChromeDriver();


        driver.get("http://localhost:4848/sense/app/C%3A%5CUsers%5Cpramod.STAR%5CDocuments%5CQlik%5CSense%5CApps%5Cdailyreportsample/sheet/PTdBnn/state/analysis");
        driver.findElement(
                By.cssSelector("div.qui-buttonset-left ng-scope button.qui-popover-button.qui-dropdown.ng-scope.ng-isolate-scope.qui-button"))
                .click();

        WebElement element = driver.findElement(By.name("a"));

        element.submit();
        driver.quit();
    }

}

I tried with xpath also not getting. My xpath helper displays the below query when i click on the button.

/html[@class='touch-off']/body[@class='qv-client qv-story-disabled qv-sheet-enabled qv-view-sheet']/div[@class='qv-panel-wrap']/div[@id='qv-toolbar-container']/div[@class='ng-scope']/div[@class='qui-toolbar']/div[@class='qui-buttonset-left ng-scope']/button[@class='qui-popover-button qui-dropdown ng-scope ng-isolate-scope qui-button'][2]

HTML code Snippet: of Button

<button class="qui-popover-button qui-dropdown ng-scope ng-isolate-scope qui-button" tid="2fedac" data-ng-disabled="quiModel.isDisabled()" data-ng-class="buttonClasses" data-icon="toolbar-menu" q-title-translation="Toolbar.Menu" data-qva-activate="onClick()" qui-model="globalMenuButton" ng-if="!isSmallDevice" title="Menu"></button>
5
  • can you please provide the HTML code snippet for the web element. Commented Oct 30, 2015 at 9:52
  • Actually, this is a web application used for business analytics. i am opening with the web browser using localhost:4848 i am not able to view the page source. Commented Oct 30, 2015 at 9:58
  • <button class="qui-popover-button qui-dropdown ng-scope ng-isolate-scope qui-button" tid="2fedac" data-ng-disabled="quiModel.isDisabled()" data-ng-class="buttonClasses" data-icon="toolbar-menu" q-title-translation="Toolbar.Menu" data-qva-activate="onClick()" qui-model="globalMenuButton" ng-if="!isSmallDevice" title="Menu"></button> Commented Oct 30, 2015 at 10:03
  • try with ==> By.cssSelector("div.qui-toolbar > div > button:nth-child(2)") Commented Oct 30, 2015 at 11:03
  • out of luck not working. Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (86, 22). Other element would receive the click: <div class="rain rain-loader qv-block-ui ng-scope" ng-class="{'qv-fade-out': fadeOut, 'qv-transparent-background': transparentBackground}" tid="3e1f54">...</div> Commented Oct 30, 2015 at 12:04

3 Answers 3

0

Try adding wait(Implicit/Explicit) after the page is loaded and you should modify your css Selector as below:

driver.findElement(By.cssSelector("div[class^='qui-toolbar']>div>button")).click();
Sign up to request clarification or add additional context in comments.

6 Comments

can you explain how can i use the wait(Implicit/Explicit)
Implicit wait:: driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); here 10 is the number of seconds. Explicit wait: WebElement myDynamicElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicElement"))); For more Information refer to "seleniumhq.org/docs/04_webdriver_advanced.jsp"
I used the below code also but not working. driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Can you please tell what exception is being thrown? There must be some exception or error message that is displayed in the console.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (86, 22).
|
0

Try the following XPATH locators for the same.

driver.findElement(By.xpath("//button[@class='qui-popover-button qui-dropdown ng-scope ng-isolate-scope qui-button']")).click();

Or

driver.findElement(By.xpath("//button[@title='Menu']")).click();

Comments

0

This worked for me.

WebElement menuButton = driver.findElement(By
                    .cssSelector("button.qui-popover-button:nth-child(2)"));
            menuButton.click();

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.