WebDriver : Right Clicking Issue - java

WebElement element = driver
.findElement(By
.xpath("html/body/div[7]/div[2]/div/div[2]/div[1]/div[2]/div/div/div/div[2]/div[1]/div[1]/div/div[2]/div/table/tr/td[1]/div[2]/div[2]/div/div[3]/div/div/div/div/div/div[1]/div[2]/div[9]/div[4]/span/a/div/div[3]/div[2]"));
Actions builder = new Actions(driver);
builder.contextClick(element).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN)
.sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();
System.out.println("right click should work now");
Hello guys!
I'm having trouble working on with the right click feature of Selenium WebDriver. As you can see above, I tried to execute that code (without error) but still WebDriver won't right click my desired page element.
I am currently writing test scripts for gmail file download. (Right Click + Save Link As)
I've tried Firefox profiling and it seems to work, but I think it's better if I will be able to test this way of downloading attachments.
Please advise.
Thanks a lot!

Related

Actions class sendkeys down-arrow does not work in any browser

enter image description hereHi,Iam new to selenium and java testing. Iam trying to right click on google.com about link and open the link in new window. Up to right click my code works fine. When I send down-arrow nothing happens in the browser. Can anyone tell what's wrong with the code. I have tried it in all different browsers.

How can I open an url after close selenium webdriver?

I have a special problem. I made a software in java, what strore informations from a website. But this website shows this data, just if I click a button. It's a simple webdriver problem, but I can click a button only 10 times. It's a very big problem form me, and I cant't do this. :D
The site counts my clicks, if I reach ten clicks, it tells me, I should login. But, it possible to login only with facebook or google account. I don't want to login with facebook or google.
The solution is, I have to close the browser, and I have to reopen that. How can I do this:
driver.close();
driver = new FirefoxDriver();
Okay, but every time when I use this formula, the java code opens a new webdriver. What is the solutin of this problem? Maybe driver.quit(); ??
No!!
If I quit the driver, I can't create a new driver. So, when I open the 321654th webpage, I have 321654/10 webdriver among Windows tasks.
What is the real solution?
Have you tried deleting cookies? You might also then have to refresh the page.
driver.manage().deleteAllCookies()
Try with refresh your page instead of close. Use below code:
driver.navigate().refresh();

Select the "back" button of the Firefox browser to right click and Select the Option from the right click Menu in Selenium Web Driver - Java

I am using Selenium webdriver . I want to select the "back " button of the firefox and right click the back button and select an option.
I see there is "Actions" API to right click, But i am not able to select/find the "back" button element of the firefox to right click using selenium .
Can any one please help me .
Code iam trying is :: Using firefox Driver to inittate the Webdriver
Actions action= new Actions(driver);
action.contextClick(productLink).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform();
In the above code , in place of "productlink", i should select the back button element of the firefox browser to right click .
You cannot do that with Selenium.
You can use AutoIT with Selenium to click on that.
Refer to the following article on how to use AutoIT.
http://toolsqa.wpengine.com/selenium-webdriver/autoit-selenium-webdriver/
Here is what you can do. Try to use "Navigation" Commands in selenium.
driver.navigate().to("http://www.DemoQA.com");
there are many commands you can perform on it. If you still find issues using it let me know.

Selenium Java trying to click with remote webDriver

I have to test with selenium a Web Application.
This :
action.moveToElement(webElement,x,y).build().perform();
Is working for 99% of my web elements...
Now I have a web element that is not detected by Selenium IDE.
My boss explains to me that this web element is a kind of plugin. This web element display video from camera.
When I try with Selenium IDE my click isn't detected.
That's why I tryed to do it with action.moveToElement(webElement,x,y).build().perform();
I have a webPath (CSS XPath) for this web element. When I try
webdriver.findElement(By ...).click();
It's not working but I don't have an exception. I guess Selenium do a click and I don't understand why it's not working.
dailymotion.com is like youtube.com (I can't use youtube at work...)
When I try to click on pause on a daylimotion video Selenium IDE don't detect my click. I guess this is the same problem.
I have found this constructor : public Actions(Keyboard keyboard, Mouse mouse) but I don't know how to use it.
I think I can't use java.awt.Robot because I'm working with Selenium grid and I have a lot of node...
Any suggestion ?
If can't able to find the webelement you can use coordinates to simulate click..
Actions builder = new Actions(driver);
Action action= builder.moveByOffset(40, 40).build();//change the x and y coordinate accordingly
action.perform();

Finding a tab within a page using selenium webdriver

I am a newbie to selenium and am trying to access the tab full score card tab on the folloing website.
http://www.espncricinfo.com/icc-womens-world-cup-2013/engine/current/match/594903.html.
My code in Java is :
driver.get("http://www.espncricinfo.com/icc-womens-world-cup-2013/engine/current/match/594903.html");
driver.manage().timeouts().implicitlyWait(5L, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[#id='st_1']")).click();
However it does not seem to be able to find the tab. Can you please help.
Thanks
The "tab" is in an iframe
Before you can do anything with an element in an iframe, you have to "activate" the frame with driver.switchTo().frame("live_iframe")

Categories

Resources