Problem: On a web page> + icon>clicking on it>opens a small widget on same page. it has iframe to access the fields, so switch to iframe. after this need to click on a button which does not come under any iframe. So I was trying to come out of iframe by switchto().defaultcontent() but this is not working. And as a result that button is not found.
I can confirm that with Selenium.WebDriver.ChromeDriver v99 switchTo().DefaultContent() is not working, once you selected a new frame switchTo.Frame(1)
Related
There is app called Raaga. I'm trying to automate this application using Appium and selenium but when I launched the app after splash screen a popup comes asking "Choose account for Raaga" as soon as the popup gone then there is screen which ask for login and sign up stuff but when I try to find the element it always throw no element found. Please let me know if m wrong I'm new to this. Thanks.
Here is my code:
TouchAction act = new TouchAction(driver);
act.tap(241,320).perform();
synchronized (driver)
{
driver.wait(4000);
}
driver.findElementByAndroidUIAutomator("new UiSelector().text(\"SIGN IN\")").click();
Here is first screen where the pop up comes
This is second screen which comes after the popup and I want to click on the "SIGN IN" button
Screenshot of UiAutomator with SIGN IN button selected.
So, you should try by using resource-id or xpath
driver.findElement(By.id("user_signin_btn")).click();
or
driver.findElement(By.id("com.raaga.android:id/user_signin_btn")).click();
or
driver.findElement(By.xpath("//*[#text='SIGN IN']")).click();
https://mahabhulekh.maharashtra.gov.in/ click on the link to see the site
I want to download a file from a site made in Angularjs. On first page there are 6 links which I have to crawl one by one. Selecting any link will lead to a page having 3 Dropdown.
Select District from dropdown which lead to related talukas in second dropdown.
Select Taluka from dropdown which lead to related Villages in third dropdown.
Select Village.
Now there is radio buttons from which I have to select the one which has survey number.
Now have to insert some digits and Click on Button. Now on the same page a dropdown will be shown from which I have to select all the options one by one and Click on button, the related file will get downloaded in pop up, so have to allow popups.
Code I have done is in selenium. I have just Clicked on the link on first page and traversed to second but now have to select dropdown but dont know how to do this as this site used Angularjs
System.setProperty("webdriver.chrome.driver","D:\\chromedriver1.exe");
WebDriver driver = new ChromeDriver();
final NgWebDriver ngDriver;
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
String baseUrl = "https://mahabhulekh.maharashtra.gov.in/";
// launch Fire fox and direct it to the Base URL
driver.get(baseUrl);
driver.findElement(By.partialLinkText("अमरावती")).click();
There's really nothing special about this being built with AngularJS. You don't show what you've tried after clicking on the link from the first page, so i'm guessing that you just need some guidance of what to do next.
If you inspect the new page, you'll see that there is a "select" webElement that you need to interact with. (be sure to use WebDriverWait to wait for the control to be available). There is a convenience class for interacting with these elements:
from selenium.webdriver.support.ui import Select
Here's the first dropdown:
dist_select = Select(driver.find_element_by_id('distSelect'))
select.select_by_value('string:5')
I am trying to automate 'Tableau' login screen and download reports flow. Everything works fine till I reach the 'Download' button. The first problem is I am NOT able to right click on the Download button and do an 'Inspect' in Chrome which is weird. I somehow am able to find the xpath by going through the whole page. When i try to click it I get "Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div[2]/div/div[3]/div[4]/span[1]"}".
The code that I am using is mentioned below:
String xPath = "/html/body/div[2]/div[2]/div/div[3]/div[4]/span[1]";
(new WebDriverWait(driver, 20))
.until(ExpectedConditions.elementToBeClickable(By.xpath(xPath)));
driver.findElement(By.xpath(xPath)).click();
The page layout is like this from where I am picking the xpath
<div class="tabToolbarButton tab-widget" style="-webkit-user-select: none; -webkit-tap-highlight-color: transparent; width: 77.4px;">
<span class="tabToolbarButtonImg tab-icon-download"></span>
<span class="tabToolbarButtonText">Download</span></div>
<span class="tabToolbarButtonImg tab-icon-download"></span>
<span class="tabToolbarButtonText">Download</span>
</div>
Any help would be appreciated. What could be the reason for not able to 'Inspect'??
If you are not able to right click on the element, you can still right click anywhere on the page and select Inspect this element. You can then grab little binocular icon(tool tip message-select an element in the page to inspect it) and point it to the desired web element to check the xpath.
1st thing you need to check if you are writing xpath correctly. On a chrome you can do that without any plugin. On the developer window(same window which gets open when you select Inspect Element option), look for Console window and write your xpath as mentioned below and hit Enter.
$x("Write x path here")
for e.g. xpath for google search box
$x("//input[#id='lst-ib']")
I'm not sure why you writing absolute xpath. Its a bad practice. You can write x path for Download button in better way.
e.g.
(//span[#class='tabToolbarButtonText'])
I got the problem. So it seems the web page I was trying to automate has used frames. That is why even after providing the xpath the element was not getting clicked. I had to use 'switchTo.frame' in order to get the frame in focus and then I was able to click the element. Thanks for all the responses.
What I have still not understood is that why I was not able to inspect the element directly but that is a different question.
I am having 2 problems in below code.
// http://jsfiddle.net/Jfw9R/7/
Validation is not working when i try to run the application as main page - applicationpage.aspx page. but when i use any html page for main page validation is working fine.
when i click on edit at list.html page. it is redirecting me to edit.html page. that is ok. but data is not coming for the employee for whom i want to edit. data only coming when i change some text in any input control. i don't why ?
Thanks
1 now this is done as i have to provide there ng-form tag instead of form in child page. which is edit.html –
I am trying to upload a file through selenium webDriver but selenium gives an error:Unable to locate element. I have used all method to find element and click on browse but not any click occurring on that.
The HTML is <input type="file" onmousedown="this.blur();" onclick="//this.blur();" onchange="$('file-loader').show(); this.form.submit();" name="metadata_item" id="metadata_item">
First check the input element is visible
Then, you don't have to click on the browse button, it will trigger an OS level dialogue box and effectively stop your test dead.
In order to deal with this follow this code:
driver.findElement(By.id("myElementId")).sendKeys("<pathToFile>");
myElementId is the id of that element (button in this case) and in sendKeys you have to specify the absolute path of the content you want to upload. The Webdriver will do the rest for you.
Keep in mind that the upload will work only If the element you send a file should be in the form
cant answer without HTML code.
in order to click Browse button place the pointer in previous field i.e,
email address field and use
Robot robot=new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
and then a system popup displays then use AutoIT tool to handle it
It could be under another frame.
Try switching to that frame and click the element.
It would work.
For Example - If the browse button is under another frame which has Id = "frameUpload", then switch the webdriver to that frame like this:
driver.switchTo().frame("frameUpload");
Now click on the browse button like this:
driver.findElement(By.Id("Id of the button")).click();
once you are done with the click, you can always get back to the default window like this
driver.switchTo().DefaultContent();