• Soheil A.
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi all, 

i have tried again several hours to find a solution for the following problem. I have a button in the frontend that does not have a unique name nor ID with which i can access it through silenium to click it. Only solution i have is xpath. 

This is the story: 

I try to click the button through this way: 
WebElement myButton = webDriver.findElement(By.xpath("//*[@class='here is the xpath to my button']"));
myButton.click();
it throws an exception saying this: 
</button> is not clickable at point (1851, 325). Other element would receive the click:

i have googled and found 3 possible solutions: 

1. add implicit wait
WebDriverWait wait = new WebDriverWait(webDriver, timeout);
webDriver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
element = wait.until(ExpectedConditions.elementToBeClickable(MYBUTTON));
wait.until(ExpectedConditions.elementToBeClickable(MYBUTTON)); 
MYBUTTON.click();
still the same error from above: </button> is not clickable at point (1851, 325). Other element would receive the click:

2. use action with offset
Actions action = new Actions(webDriver);
action.moveToElement(myButton, 0, -20).contextClick().perform();
action.moveToElement(myButton, 0, -20).click().perform();
action.moveToElement(myButtons, 0, -20).doubleClick().perform();
result: nothing happens. it does not click the element. but context click is shown on the button itself. strange that click does not work. 

3. use javascriptexecutor with offset
((JavascriptExecutor)webDriver).executeScript("window.scrollTo(0,"+clickableAddProduct.getLocation().x+")");
clickableAddProduct.click();
result: still the same error from above: </button> is not clickable at point (1851, 325). Other element would receive the click:

4. execute java script with javascriptexecutor
js.executeScript(	"window.document.getElementByxpath('XPATH TO MYBUTTON').click()");
Result: no such method getElementByxpath exists 

only possible solution i have test is:
- give the button an ID (for example ID="unique ID of MYBUTTON"). during runtime in the inspector of chrome (F12)
- try this below
try {
			// Find the element...
			WebElement element = MYBUTTON;

			// Step 1
			new Actions(webDriver).moveToElement(element).perform();

			// Step 2
			element.click();
		} catch (Exception e) {

			((JavascriptExecutor) webDriver).executeScript("document.getElementById('unique ID of MYBUTTON').click();");

		}

code then it works withe the java script executor line (the one in the exception). i debugged it. worked. 

please can someone help. tried so many ways. frustrating. :(

Thanks
Soheil



 
Hi All, 

i have tried now several solutions available in the net related to my below problem without a success. Now came to the idea to use the community for the first time! :) 

This is my problem: 
I am using Silenium (Java framework) with Eclipse to test salesforce in automated frontend testing. I read that even salesforce doest that too. But strangely i cannot access the lookup popup (which is shown when you click on any lookup button) through silenium. 

With this i have tried to "debug" what is inside the frame: 
List<WebElement> ele = webDriver.findElements(By.tagName("frame"));
// show how many frames are defined with the tag "frame"
            System.out.println("Number of frames in a page :" + ele.size());
            for(WebElement el : ele){
              //Returns the Id of a frame.
                System.out.println("Frame Id :" + el.getAttribute("id"));
              //Returns the Name of a frame.
                System.out.println("Frame name :" + el.getAttribute("name"));
}

Result: "Number of frames in a page : 0"

Second Solution (with no success):
webDriver.switchTo().defaultContent();
// find the new popup window that i have opened previously with the lookup button
webDriver.switchTo().frame("searchFrame");
// find the search field in the new dialog box
WebElement element = webDriver.findElement(By.id("lksrch"));
element.sendKeys("my Company Name to use in popup");

Can anyone tell me how salesforce does that? Or what i am doing wrong? 

Bye
Soheil
Hi All, 

i have tried now several solutions available in the net related to my below problem without a success. Now came to the idea to use the community for the first time! :) 

This is my problem: 
I am using Silenium (Java framework) with Eclipse to test salesforce in automated frontend testing. I read that even salesforce doest that too. But strangely i cannot access the lookup popup (which is shown when you click on any lookup button) through silenium. 

With this i have tried to "debug" what is inside the frame: 
List<WebElement> ele = webDriver.findElements(By.tagName("frame"));
// show how many frames are defined with the tag "frame"
            System.out.println("Number of frames in a page :" + ele.size());
            for(WebElement el : ele){
              //Returns the Id of a frame.
                System.out.println("Frame Id :" + el.getAttribute("id"));
              //Returns the Name of a frame.
                System.out.println("Frame name :" + el.getAttribute("name"));
}

Result: "Number of frames in a page : 0"

Second Solution (with no success):
webDriver.switchTo().defaultContent();
// find the new popup window that i have opened previously with the lookup button
webDriver.switchTo().frame("searchFrame");
// find the search field in the new dialog box
WebElement element = webDriver.findElement(By.id("lksrch"));
element.sendKeys("my Company Name to use in popup");

Can anyone tell me how salesforce does that? Or what i am doing wrong? 

Bye
Soheil