I am using nexus 5 to test. How can i choose image from gallery using appium in android. When i used following code :
driver.findElement(By.xpath("//android.widget.ImageView[#content-desc='Photo
taken on 13 May 2016 12.50']")).click();
I got such Exception:
Exception in thread "main"
org.openqa.selenium.NoSuchElementException: An element could not be
located on the page using the given search parameters. (WARNING:The
server did not provide any stacktrace information) Command duration
or timeout: 50.56 seconds
Try with this:
driver.findElement(By.xpath("//*[#class='android.widget.ImageView' and #content-desc='Photo taken on 13 May 2016 12.50']")).click();
Try to write it with this manner it will select only the first :
driver.findElement(By.xpath("//android.widget.ImageView[contains(#resource-id,'id of your image')]")).click();
With this code you can select any elements you want just put instead of i the element you want starting from 0 for the first one :
driver.findElements(By.xpath("//android.widget.ImageView[contains(#resource-id,'id of your image')]")).get(i).click();
The best way is to go by creating xpath!
find_element(xpath: "//android.widget.FrameLayout[1]").click
Change your class name accordingly if different.
Related
I am writing the code line as:
driver.findElement(By.id("com.android.vending:id/0_resource_name_obfuscated")).click();
//Clicking on No Thanks button - resourceid take from Ui Automator
But appium does not respond to this line and give error that no element found.
"An element could not be located on the page using the given search parameters"
Any help? Thanks in advance
Instead of tapping on No Thanks, I used back button
driver.navigate().back();
Query has been resolved with alternate method.
Try to use wait methods :
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.visibilityOfElementLocated((By.id("com.android.vending:id/0_resource_name_obfuscated")));
//Or use condition: elementToBeClickable()
Since our test agents are slow some times- i am trying to add some additional time outs for some commands
I did it like using time out value on command as shown below.But its not respecting the value given
My understanding is cypress will wait for "10000" MS for getting the #Addstory element?
Can any one advice is this is the correct way please?
Thank you so much
cy.get('#addstory > .ng-scope').click({ timeout: 10000 })
In cypress.json file, increase the timeout to 10 seconds or what ever timeout you want like this: "defaultCommandTimeout": 10000 and save the file. Now close the app and open it again. Navigate to Settings > Configuration you should be able to see the new value set for defaultCommandTimeout.
I issue was i was adding time out on click not for getting the element when i changed like below -All good waiting for add story to be visible as i expected before click
cy.get('#addstory > .ng-scope',{ timeout: 10000 }).click()
I am creating a label printing function in a program that needs to create labels for the given information. I have created a label in Crystal Reports 9 but I'm having trouble printing it.
I don't want to save the label, I just want it to print directly after the system has created it.
Dim ap9 As craxdrt.Application
Dim rpt9 As craxdrt.Report
Dim dbt As craxdrt.DatabaseTable
Set ap9 = New craxdrt.Application
On Error GoTo errError2
Set iniFile = New CIniFile
On Error GoTo errError3
Set rpt9 = ap9.OpenReport(iniFile.pathReports & REPORT_LABEL_IN)
On Error GoTo errError4
For Each dbt In rpt9.Database.Tables
dbt.Location = iniFile.pathDbCosmet
If dbt.ConnectionProperties.count <= 5 Then
dbt.ConnectionProperties.Add "Database Password", iniFile.passwordCosmet
End If
Next
rpt9.RecordSelectionFormula = sFormula
rpt9.PrintOut False, CInt(txtPacksReceived.Text)
The following code allows me to select a printer
and after clicking 'Print' at that point I am shown another dialog
However, the code executes fine, there are no errors, but the print queue doesn't show any documents and the report doesn't print.
Is there some reason why I'm not able to print my labels?
I've had problems with Zebra printers in the past that all turned out to be driver related. Have you uninstalled the printer driver and reinstalled it? Otherwise try unplugging and removing the device, plugging it into a different port and trying again?
Most likely your report doesn't contain any data - some logical error in selection/suppression formulas or similar.
If you print to any other printer, does something print out? Tracing SQL (assuming your report is bound to SQL server), can you see issued query? Does it look correct?
Hi I'm a new user of selenium. I'm trying to take a screenshot of an alert using selenium webdriver in ruby.
#driver.find_element(:name, "updateButton").click
#driver.save_screenshot "./#{Time.now.strftime("Alert_Screenshot___%d_%m_%Y__%H_%M_%S")}.png"
Instead of taking a screenshot, this error is thown:
Selenium::WebDriver::Error::UnhandledAlertError
Of course I can accept the alert:
#driver.switch_to.alert.accept
and then take a screenshot. But I want to know is there way to take the screenshot while the alert is being prompted?
In your case you need to take screenshot for complete screen, not only the browser. So you can use xwd to take a screenshot of the root window:
xwd -display :0 -root|xwdtopnm |pnmtopng > $1
I have been trying to run some sample Remote WebDriver tests on the Safari browser on the IOS Simulator 7.0 (IPhone) but my tests give an exception every time I try to type in values on a text box. Just trying to use the example from iosdriver
DesiredCapabilities safari = IOSCapabilities.iphone("Safari");
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://<someip>:4444/wd/hub"), safari);
driver.get("http://hp.mobileweb.ebay.co.uk/home");
WebElement search = driver.findElement(By.id("srchDv"));
search.sendKeys("ipod");
search.submit();
gives me the exception
a "org.openqa.selenium.NoSuchElementException: cannot find element for criteria :{"AND":[{"l10n":"none","expected":"UIAElement","matching":"exact","method":"type"},{"l10n":"none","expected":"Address","matching":"exact","method":"name"}" .
Anyone else run into this? It is identifying the element but typing in values fail..It works fine when I try it on firefox on my desktop.
I am no expert, but am familiar with selenium webdriver..
Are you sure that the id for "search " --- ('srchDv') actually exists on the page you are trying to automate?
if so
i would then look into the UIA -Element Hierarchy / Accessibility link to UIA Element Class reference
Hope this is helpful
You have an incorrect selector. The page you are automating does not have an id srchDv. If you are getting the search box, then you need to use:
driver.findElement(By.id("gh-ac")).clear();
driver.findElement(By.id("gh-ac")).sendKeys("ipod");
Also, instead of using submit, personally i would follow the way that your user would commit the action, and that's by clicking the search button.
driver.findElement(By.id("gh-btn")).click();