I am trying to automate Adobe CQ5 with Selenium webdriver.
I am finding it difficult to right click on content pages on right hand pane.
If anyone succeeded working with context menu on right hand pane/content pages, please guide me with approach which worked.
Let me provide you more details of the issue I am facing:
I have article with the name 'MyArticle' and I am trying to right click and open it. When I am using below piece of code I am not getting context menu itself so that I can work on it.
Actions action = new Actions(myD);
WebElement wb =myD.findElement(By.xpath("//table/tbody/tr/td/div[contains(text(),'MyArticle')]"));
Action rightClick = action.contextClick(wb).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build();
rightClick.perform();
I tried different ways but getting error while locating the element, any clue would be really helpful.
Thanks,
Pankaj
I am not sure if I understand your question. I am assuming you are in WCM, trying to open a page for editing.
The code below works for me in CQ 5.6, Selenium 2.25 in both IE and FF.
WebElement tableRow = driver.findElement(By.id("cq-siteadmin-grid"))
.findElement(By.xpath(".//div[text()='YOUR_PAGE_TITLE_HERE']"));
new Actions(driver).contextClick(tableRow).perform();
WebElement menu = driver.findElement(By.xpath("//div[contains(#class, 'x-menu') and contains(#style, 'visible')]"));
menu.findElement(By.xpath(".//span[text()='Open']")).click();
Let me know if it helped.
Related
I am quite new to Selenium Web driver and I suppose this is a basic question.
Anyway, I am having troubles in switching to a quick view window. Let me explain this with the image below
We got this by visiting amazon.com and hit "Quick look" on any item.
Now, suppose I want to click on the button "See product details",
how can I do this?
Do I have to accept the alert and then click? Like this java code for example
driver.switchTo().alert().accept();
driver.findElement(By.xpath("xpath")).click();
I tried this and does not work.
How can handle situations like this? Any idea?
Thanks a lot.
"Quick look" modal window is not an alert. You just need to wait until it appeared in DOM. Try to add below code to your existed after you clicked "Quick look" button:
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("See product details"))).click();
I'm doing a test on c# with selenium for this site http://onliner.by.
At first I have to be authorized on this site.
I found(by xpath) button with name"Вход" in the right upper corner and click on it.
Then there's refreshed and page changed, but the link remained the same (http://onliner.by).
And I need to enter login and password on this page and sumbit it. But I cannot do it.
I founded Xpath paths of this elements and I used this code:
//this doesn't work
driver.FindElement(By.XPath("//*[#id='auth-container__forms']/div/div[2]/form/div[1]/div[1]/input")).SendKeys("user");
driver.FindElement(By.XPath("//*[#id='auth-container__forms']/div/div[2]/form/div[1]/div[2]/input")).SendKeys("password");
driver.FindElement(By.XPath("//*[#id='auth-container__forms']/div/div[2]/form/div[3]/div/button")).Click();
How can I do it? I tried to use SwitchTo().Frame but it didn't help too.
I will be very grateful for help.
You have to wait element availablity like this
new WebDriverWait(driver, TimeSpan.FromSeconds(timeOut)).Until(ExpectedConditions.ElementExists((Locator Value)));
I am trying to click the main menu items in seleniumhq.org but after clicking on the first link i am getting a StaleElementReferenceException:Element not found in the cache=perhaps the page was changed since it was looked up
Please provide solution to solve the above problem
Below was my code
WebDriver d=new FirefoxDriver();
d.get("http://docs.seleniumhq.org/");
d.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);
List<WebElement> l=d.findElements(By.cssSelector("ul>li"));
for(WebElement e:l) {
e.click();
}
Thanks in advance
If you click on a link and you are taken to the different page or even if you stay in same page the DOM is refreshed. Those elements are not attached to DOM anymore. You need to write some code to come back to previous page if your click takes you to a different page or even if you stays in same page you have find the link on the fly to click instead of "e.click()"
Please help, I'm new in Selenium. I try to automate eCommerce website and I have problem to handle popup window. Here is the scenario:
Go to http://www.lampsplus.com
Click on Sale link in the header section.
Click on the 1st item/product displayed on the page. (This will show the product page).
On the product page, click on the red Add To Cart button. (This will add a product to cart and display a popup).
On the popup, click the dark-grey Continue Shopping button. (This will close the popup.)
I stuck on step 5 (Error message: Unable to locate element "Continue shopping button")
Here is my code before step 5:
WebDriver d1 = new FirefoxDriver();
d1.manage().window().maximize();
d1.get("http://www.lampsplus.com");
d1.findElement(By.name("hdr_sale")).click();
d1.findElement(By.xpath(".//*[#id='sortResultContainer60238']/a[2]/span")).click();
d1.findElement(By.id("pdAddToCart")).click(); //This is step 4
//Here is suppose to be some code which handles the popup - my problem
d1.findElement(By.id("aContinueShopping")).click(); //This is step 5
I'm aware about .getWindowHandle(); method. I tried several variations of it and none of them worked.
Can anyone give me an idea how to handle it. Many thanks! I use Java.
Note: I don't work for LampsPlus and not try to promote their products, this website was chosen for training purposes only.
The element aContinueShopping is contained within an iframe.
You'll have to switch to the iframe using:
WebElement frameID = d1.findElement(By.Css("#add-to-cart>iframe"));
d1.SwitchTo().Frame(frameID);
d1.findElement(By.id("aContinueShopping")).click();
There's no 'name' or 'id' on the iframe, so you'll have to use a WebElement or a numeric to find it.
Once you're done with that iframe, you'll switch back to 'top' by using:
d1.SwitchTo().DefaultContent();
I am trying to Click on a link and check that it is active. However the class is what is determining whether it is active or not.
This is for pagination for a web page where i want to automate the web driver to navigate to different pages and ensure the link click has indeed taken the user to the correct page.
I am using Selenium2Library with firefox.
Does anyone have any suggestions. Thanks.
Here's solution in Java, I hope you can translate it to whatever language you use.
WebElement link = driver.findElement(By.cssSelector("[title='No. 2']"));
String linkClass = link.findElement(By.xpath("./..")).getAttribute("class");
if ("active".equals(linkClass)) {
link.click();
}