-
-
Notifications
You must be signed in to change notification settings - Fork 765
find element by nspredicate string. #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ## Setting Up XCUITest | ||
| --- | ||
|
|
||
| **Install Appium XCUITest Driver** | ||
|
|
||
| Clone Appium XCUITest Driver repo https://github.com/appium/appium-xcuitest-driver | ||
|
|
||
| ``` | ||
| git clone --recursive https://github.com/appium/appium-xcuitest-driver.git | ||
| cd appium-xcuitest-driver | ||
| npm install | ||
| ``` | ||
|
|
||
| Set your appium path to the appropriate location (Where you cloned appium-xcuitest-driver) and you can | ||
| start the driver by doing: | ||
|
|
||
| ``` | ||
| node . | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/io/appium/java_client/FindsByIosNsPredicate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package io.appium.java_client; | ||
|
|
||
| import org.openqa.selenium.WebElement; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface FindsByIosNsPredicate<T extends WebElement> { | ||
| T findElementByIosNsPredicate(String using); | ||
|
|
||
| List<T> findElementsByIosNsPredicate(String using); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/test/java/io/appium/java_client/ios/XCUIDriverTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * See the NOTICE file distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.appium.java_client.ios; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertTrue; | ||
| import org.openqa.selenium.remote.DesiredCapabilities; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| import net.lingala.zip4j.exception.ZipException; | ||
| import net.lingala.zip4j.core.ZipFile; | ||
| import org.apache.commons.io.FileUtils; | ||
|
|
||
| import io.appium.java_client.remote.HideKeyboardStrategy; | ||
| import io.appium.java_client.remote.IOSMobileCapabilityType; | ||
| import io.appium.java_client.remote.MobileCapabilityType; | ||
| import io.appium.java_client.service.local.AppiumDriverLocalService; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import io.appium.java_client.MobileBy; | ||
| import io.appium.java_client.MobileElement; | ||
|
|
||
| import org.junit.*; | ||
| import org.openqa.selenium.Point; | ||
| import org.openqa.selenium.ScreenOrientation; | ||
| import org.openqa.selenium.html5.Location; | ||
|
|
||
| public class XCUIDriverTest { | ||
|
|
||
| private static final String SOURCE = "src/test/java/io/appium/java_client/"; | ||
| private static AppiumDriverLocalService service; | ||
| protected static IOSDriver<MobileElement> driver; | ||
|
|
||
| /** | ||
| * initialization. | ||
| */ | ||
| @BeforeClass public static void beforeClass() throws Exception { | ||
| service = AppiumDriverLocalService.buildDefaultService(); | ||
| service.start(); | ||
|
|
||
| if (service == null || !service.isRunning()) { | ||
| throw new RuntimeException("An appium server node is not started!"); | ||
| } | ||
|
|
||
| String source = SOURCE + "UICatalog.app.zip"; | ||
|
|
||
| try { | ||
| ZipFile zipFile = new ZipFile(source); | ||
| zipFile.extractAll(SOURCE); | ||
| } catch (ZipException e) { | ||
| String msg = "Could not extract file"; | ||
| throw new ZipException(msg, e); | ||
| } | ||
|
|
||
| File appDir = new File(SOURCE); | ||
| File app = new File(appDir, "UICatalog.app"); | ||
| DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
| capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, ""); | ||
| capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.3"); | ||
| capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6"); | ||
| //sometimes environment has performance problems | ||
| capabilities.setCapability(IOSMobileCapabilityType.LAUNCH_TIMEOUT, 500000); | ||
| capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath()); | ||
| driver = new IOSDriver<>(service.getUrl(), capabilities); | ||
| } | ||
|
|
||
| /** | ||
| * finishing. | ||
| */ | ||
| @AfterClass public static void afterClass() { | ||
| if (driver != null) { | ||
| driver.quit(); | ||
| } | ||
| if (service != null) { | ||
| service.stop(); | ||
| } | ||
| try { | ||
| FileUtils.deleteDirectory(new File(SOURCE + "/UICatalog.app")); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| //TODO There is no ability to check this function usibg simulators. | ||
| // When CI will have been set up then this test will be returned | ||
| public void getDeviceTimeTest() { | ||
| String time = driver.getDeviceTime(); | ||
| assertTrue(time.length() == 28); | ||
| } | ||
|
|
||
| /** | ||
| * Verifies UICatalog element is present in view. | ||
| */ | ||
| @Test public void getiOSElementByPredicate() { | ||
| //Needs to run on the XCUITest ios Driver (https://github.com/appium/appium-xcuitest-driver.git). | ||
| driver.findElement(MobileBy.IosNsPredicateString("identifier == \"UICatalog\"")); | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is just a comment I would format it "NSPredicate" instead of "NsPredicate"