How to switch to Telerik Radwindow using webdriver (java) - java

We are testing an application build using Telerik.
A demo of Telerik is available here: http://demos.telerik.com/aspnet-ajax/window/examples/radwindowobject/defaultcs.aspx
Our application is build in a similar way.
In this demo you can see a window with Bing in it. I want to switch to it using WebDriver (Java) to perform actions on objects within it.
I have tried to switchto iframe but WebDriver comes back saying it is not an iframe.
Also tried to get window handles and switchto window but with no luck, it is not treated as a new window. Any suggestions please?

The following code worked for me. I was able to enter text in the bing search field.
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://demos.telerik.com/aspnet-ajax/window/examples/radwindowobject/defaultcs.aspx");
driver.switchTo().frame("RadWindow1");
driver.findElement(By.name("q")).sendKeys("Hello this is my text");
Let me know if this helps you.

Related

Selenium Webdriver Java: Unable to perform click operation by Actions in Chrome

I am using Selenium Webdriver(Java) for my Automation. For one of my use-case, I need to click based on co-ordinates. I am using following code to perform this operation:
Actions act = new Actions(driver);
act.moveByOffset(236, 92).click().perform();
Above code is working perfectly in Firefox(Gecko driver). But with Chrome driver, it is not working. Any idea?
Is there any other way to perform this.
I think you can try what Santosh has suggested
act.moveByOffset(236, 92).click().build().perform();
However, this should not make much of a difference as the perform() already contains the build action but this might be a workaround for your problem.
If you can locate the webelement, you can use JavaScript to perform the click this way:
JavaScriptExecutor js = (driver)JavaScriptExecutor;
js.executeScript("arguments[0].click();", element);

Windows handling in Selenium webdriver using java

I have a scenario as below
1. Login to the application
2. click on a button (say Buy)
3. This will take me to a new window opened with a new URL automatically
4. Perform actions in the new window
5. Quit
Kindly please provide the exact code to work on this. I tried with the available code that exists in the website which didnt work for me
You can try on following pattern:-
Webdriver driver = new ChromeDriver();
driver.get("URL of application");
driver.findElement(By.id("username").sendKeys("user1");
driver.findElement(By.id("password").sendKeys("pass1");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.findElement(By.xPath("xpath of button").click();
//now you can switch to pop-up and accordingly accept or dismiss it
driver.switchTo().alert().accept();
driver.quit();
In case you provide the SO community the URL of application then only complete code can be provided.

Actions Class in Selenium Webdriver

I am trying to perform the Control+A operation using the Actions class in Selenium using the following query:-
driver.get("https://jqueryui.com/datepicker/");
new Actions(driver).keyDown(Keys.CONTROL).sendKeys("a").keyUp(Keys.CONTROL)
.build().perform();
However , instead doing Control+A for the contents on the Webpage , it is performing the same operation in the URL bar. Could someone please let me know what is the error here.Moreover the issue what i see is the control stays in the URL bar and it doesnt come down to the Webpage.
I think there is an issue with pressing keys in selenium 3.0 which is reported here Actions sendKeys UnsupportedCommandException with geckodriver
You can try following alternative way to do that -
driver.findElement(By.xpath("//body")).sendKeys(Keys.chord(Keys.CONTROL, "a"))

Accessing drop down list- selenium webdriver & java

I am trying to write a few test cases for automation testing as a part of practice assignment in selenium webdriver using java.
The java version is 1.6 and selenium webdriver version is 2.39 while firefox browser version is 29.0.1.
I am trying to access the drop down titled CARSIZE in the following link:
http://www.carrentals.com/
I am not able to manipulate it.
I have tried the following code...
driver.get("http:\\www.carrentals.com/");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Select dropdown= new Select(driver.findElement(By.xpath("//*[#name='carType']")));
dropdown.selectByValue("carsize-1");
With the above code, it seems that I am able to find the element(as no exception is thrown) but not change a value. When I try to change a value by SELECTBYVALUE method, I get an exception saying element not visible. Can someone help me?
The Html code for the above can be seen in firebug and just for information I have also tried using ID and name instead of XPath for the concerned select box but I get the same exception.
Try this:
Select dropdown= new Select(driver.findElement(By.xpath("//select[#id='cartype']")));
dropdown.selectByVisibleText("Small Cars");
Updated.
Try this code. It works for me.
String dropdownXpath = "//label[#for='cartype']/following-sibling::div[#role='listbox']";
WebElement textInDropDown = webDriver.findElement(By.xpath(dropdownXpath + "//div[#class='text']"));
textInDropDown.click();
webDriver.findElement(By.xpath(dropdownXpath)).sendKeys("Small Cars");
It locates text in dropdown element and then sends value which you want to select.

Changing URL using WebDriver

I'm using Selenium WebDriver (Java) and am trying to change the URL after WebDriver has logged into a page.
Is there a way to either:
Change the URL of the current window, or
Open a new tab and go to another page.
Thanks!
You didn't share any code so i don't know how is your approach about it, I only share my knowledge about this subject.
1) For your first question i think you know how to open a new page with selenium web driver maybe you can use some wait method and then invoke the driver again.
//open browser
driver = new FirefoxDriver();
//login
driver.get("https://www.google.com/");
//set implicit wait
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//Then invoke method again for your second request(I am not try this code maybe you need to create new driver object)
driver.get("https://www.stackoverflow.com");
2) For your second question this link help you.

Categories