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();
Related
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)
please create a selenium code for us where i am not able to hit the Login Button. see my code below and do the correction :
driver.findElement(By.id("Log In")).click();
driver.findElement(By.className("submit")).click();
driver.findElement(By.cssSelector(".sbt-btn-wrap relative .submit")).click();
driver.findElement(By.className("formButton")).click();
Try this below xpath.
Explanation: User value attribute of input tag.
driver.findElement(By.xpath("//input[#value='Log In']")).click();
For click on Lock and Edit button use this code.
driver.findElement(By.xpath("//input[#value='Lock & Edit']")).click();
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.
Unable to click on button after entering the email address.
driver = new ChromeDriver();
driver.get("http://in.rediff.com/");
driver.findElement(By.xpath(".//*[#id='homewrapper']/div[5]/a[3]/div/u")).click();
driver.findElement(By.xpath(".//*[#id='wrapper']/div[2]/ul/li[2]/a")).click();
driver.findElement(By.xpath(".//*[#id='useremail']")).sendKeys("xyz");
driver.findElement(By.xpath(".//*[#id='emailsubmit']")).click();
I am supposed to see the password input box after the submit button click. For somereason I am not able to see this. Am I doing anything wrong? Not getting any errors after this line.
System.out.println("Finish");
This line is executed as well.
Your code is clicking on the Submit button perfectly.
As per the rediff functionality, if "xyz"(username) you are entering doesnt exist, then it will redirect to Login form.
So the reason you are not getting password object. Try with any existing user account(username).
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();