Skip to content

Commit

Permalink
feat: Migrates selenium and appium to latest.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Oct 5, 2023
1 parent a26a6dc commit 90938fb
Show file tree
Hide file tree
Showing 35 changed files with 134 additions and 264 deletions.
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<version>4.13.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.59</version>
<version>4.13.0</version>
</dependency>

<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.5.0</version>
<version>5.5.3</version>
</dependency>

<dependency>
Expand All @@ -57,7 +57,8 @@
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
<!-- <version>6.1.0</version>-->
<version>8.5.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
Expand All @@ -75,6 +76,12 @@
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>

<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/jitsi/meet/test/ActiveSpeakerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.testng.*;
import org.testng.annotations.*;

import java.time.*;
import java.util.*;

import static org.testng.Assert.*;
Expand Down Expand Up @@ -162,7 +163,7 @@ private void testActiveSpeaker(
// perspective
try
{
new WebDriverWait(driver2, 10).until(
new WebDriverWait(driver2, Duration.ofSeconds(10)).until(
(ExpectedCondition<Boolean>) d -> speakerEndpoint.equals(
MeetUIUtils.getLargeVideoResource(d)));
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/org/jitsi/meet/test/ChatPanelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.jitsi.meet.test.web.*;
import org.testng.annotations.*;

import static org.testng.Assert.*;

/**
* Checks that the chat panel can be opened and closed with a shortcut and
* with the toolbar button.
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/org/jitsi/meet/test/DataChannelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import org.testng.annotations.*;

import java.time.*;

import static org.testng.Assert.*;

/**
Expand Down Expand Up @@ -156,7 +158,7 @@ public void testDataChannelOfParticipant2()
*/
private void waitForDataChannelToOpen(WebDriver webDriver)
{
new WebDriverWait(webDriver, 15).until(
new WebDriverWait(webDriver, Duration.ofSeconds(15)).until(
(ExpectedCondition<Boolean>) this::isDataChannelOpen);
}

Expand All @@ -171,7 +173,7 @@ private void waitForDataChannelToOpen(WebDriver webDriver)
*/
private void waitToReceiveServerHello(WebDriver webDriver)
{
new WebDriverWait(webDriver, 15).until(
new WebDriverWait(webDriver, Duration.ofSeconds(15)).until(
(ExpectedCondition<Boolean>) this::isServerHelloReceived);
}

Expand Down
8 changes: 5 additions & 3 deletions src/test/java/org/jitsi/meet/test/EtherpadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.testng.*;
import org.testng.annotations.*;

import java.time.*;

import static org.testng.Assert.*;

/**
Expand Down Expand Up @@ -96,17 +98,17 @@ public void writeTextAndCheck()
// give time for the internal frame to load and attach to the page.
TestUtils.waitMillis(2000);

WebDriverWait wait = new WebDriverWait(driver1, 30);
WebDriverWait wait = new WebDriverWait(driver1, Duration.ofSeconds(30));
wait.until(
ExpectedConditions.frameToBeAvailableAndSwitchToIt(
By.id("etherpadIFrame")));

wait = new WebDriverWait(driver1, 30);
wait = new WebDriverWait(driver1, Duration.ofSeconds(30));
wait.until(
ExpectedConditions.frameToBeAvailableAndSwitchToIt(
By.name("ace_outer")));

wait = new WebDriverWait(driver1, 30);
wait = new WebDriverWait(driver1, Duration.ofSeconds(30));
wait.until(
ExpectedConditions.frameToBeAvailableAndSwitchToIt(
By.name("ace_inner")));
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/jitsi/meet/test/IFrameAPIBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.testng.*;

import java.net.*;
import java.time.*;
import java.util.logging.*;

/**
Expand Down Expand Up @@ -177,7 +178,7 @@ protected static void switchToMeetContent(JitsiMeetUrl iFrameUrl, WebDriver driv
if (iFrameUrl.getIframeToNavigateTo() != null)
{
// let's wait for switch to that iframe, so we can continue with regular tests
WebDriverWait wait = new WebDriverWait(driver, 60);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(
By.id(iFrameUrl.getIframeToNavigateTo())));
}
Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/jitsi/meet/test/PSNRTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.jitsi.meet.test;

import org.jitsi.meet.test.base.*;
import org.jitsi.meet.test.capture.*;
import org.jitsi.meet.test.tasks.*;
import org.jitsi.meet.test.util.*;
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/org/jitsi/meet/test/PreJoinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.openqa.selenium.support.ui.*;
import org.testng.annotations.*;

import java.time.*;

import static org.testng.Assert.*;

public class PreJoinTest
Expand Down Expand Up @@ -86,7 +88,7 @@ public void testJoinWithoutAudio()
preJoinScreen.waitForLoading();
preJoinScreen.getJoinOptions().click();

WebDriverWait wait = new WebDriverWait(getParticipant1().getDriver(), 5);
WebDriverWait wait = new WebDriverWait(getParticipant1().getDriver(), Duration.ofSeconds(5));
WebElement joinWithoutAudioBtn = wait.until(
ExpectedConditions.elementToBeClickable(
preJoinScreen.getJoinWithoutAudioButton()));
Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/jitsi/meet/test/StartMutedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.jitsi.meet.test.util.*;
import org.jitsi.meet.test.web.*;

import org.openqa.selenium.*;
import org.testng.annotations.*;

/**
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/jitsi/meet/test/base/Participant.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.openqa.selenium.support.ui.*;

import java.io.*;
import java.time.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
Expand Down Expand Up @@ -493,7 +494,7 @@ public void saveHtmlSource(File outputDir, String fileName)
if (getMeetUrl().getIframeToNavigateTo() != null)
{
// let's wait for switch to that iframe, so we can save the correct page
WebDriverWait wait = new WebDriverWait(driver, 60);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(
By.id(getMeetUrl().getIframeToNavigateTo())));
}
Expand Down
26 changes: 13 additions & 13 deletions src/test/java/org/jitsi/meet/test/mobile/MobileParticipant.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*
* @author Pawel Domas
*/
public class MobileParticipant extends Participant<AppiumDriver<MobileElement>>
public class MobileParticipant extends Participant<AppiumDriver>
{
/**
* The default config part of the {@link JitsiMeetUrl} for every mobile
Expand Down Expand Up @@ -73,7 +73,7 @@ public class MobileParticipant extends Participant<AppiumDriver<MobileElement>>
/**
* The Appium driver instance.
*/
private final AppiumDriver<MobileElement> driver;
private final AppiumDriver driver;

/**
* Initializes {@link MobileParticipant}.
Expand All @@ -87,7 +87,7 @@ public class MobileParticipant extends Participant<AppiumDriver<MobileElement>>
* @param appBinaryFile - A full path to the app binary file which can be
* used to install the app on the device.
*/
public MobileParticipant(AppiumDriver<MobileElement> driver,
public MobileParticipant(AppiumDriver driver,
String name,
ParticipantType type,
String appBundleId,
Expand Down Expand Up @@ -145,9 +145,9 @@ private boolean dismissAlertIfAny()
}
}

private AndroidDriver<MobileElement> getAndroidDriver()
private AndroidDriver getAndroidDriver()
{
return type.isAndroid() ? (AndroidDriver<MobileElement>) driver : null;
return type.isAndroid() ? (AndroidDriver) driver : null;
}

/**
Expand Down Expand Up @@ -259,7 +259,7 @@ private void maybeAcceptOverlayPermissions()

toggleSwitch.click();

getAndroidDriver().pressKeyCode(AndroidKeyCode.BACK);
getAndroidDriver().pressKey(new KeyEvent(AndroidKey.BACK));

logger.info("Overlay permissions granted !");
}
Expand All @@ -279,7 +279,7 @@ public void doJoinConference(JitsiMeetUrl conferenceUrl)

WelcomePageView welcomePageView = new WelcomePageView(this);

MobileElement roomNameInput = welcomePageView.getRoomNameInput();
WebElement roomNameInput = welcomePageView.getRoomNameInput();

roomNameInput.sendKeys(conferenceUrl.toString());

Expand Down Expand Up @@ -367,7 +367,7 @@ public void close()
/**
* {@inheritDoc}
*/
public AppiumDriver<MobileElement> getDriver()
public AppiumDriver getDriver()
{
return driver;
}
Expand All @@ -381,9 +381,9 @@ public void reinstallAppIfInstalled()
if (removeAppIfInstalled())
{
Logger.getGlobal().log(Level.INFO, "Installing app...");
driver.installApp(appBinaryFile);
((InteractsWithApps)driver).installApp(appBinaryFile);
Logger.getGlobal().log(Level.INFO, "Launching app...");
driver.launchApp();
((InteractsWithApps)driver).activateApp(appBundleId);
}
}

Expand All @@ -397,10 +397,10 @@ public void reinstallAppIfInstalled()
public boolean removeAppIfInstalled()
{
// FIXME driver.isAppInstalled does not work on iOS
if (type.isIOS() || driver.isAppInstalled(appBundleId))
if (type.isIOS() || ((InteractsWithApps)driver).isAppInstalled(appBundleId))
{
Logger.getGlobal().log(Level.INFO, "Removing app...");
driver.removeApp(appBundleId);
((InteractsWithApps)driver).removeApp(appBundleId);

return true;
}
Expand Down Expand Up @@ -507,7 +507,7 @@ public Filmstrip<MobileParticipant> getFilmstrip()
}

@Override
public List<RemoteParticipant<AppiumDriver<MobileElement>>>
public List<RemoteParticipant<AppiumDriver>>
getRemoteParticipants()
{
throw new RuntimeException("Not implemented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ protected MobileParticipant doCreateParticipant(ParticipantOptions options)
URL appiumUrl = targetOptions.getAppiumServerUrl();
DesiredCapabilities capabilities = targetOptions.createCapabilities();

AppiumDriver<MobileElement> driver
AppiumDriver driver
= type.isAndroid()
? new AndroidDriver<>(appiumUrl, capabilities)
: new IOSDriver<>(appiumUrl, capabilities);
? new AndroidDriver(appiumUrl, capabilities)
: new IOSDriver(appiumUrl, capabilities);

driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.jitsi.meet.test.base.*;
import org.jitsi.meet.test.mobile.*;

import java.util.*;

/**
* Base class of mobile test cases.
Expand Down
19 changes: 10 additions & 9 deletions src/test/java/org/jitsi/meet/test/pageobjects/base/TestHint.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TestHint
/**
* The mobile participant's driver.
*/
private final AppiumDriver<MobileElement> driver;
private final AppiumDriver driver;

/**
* The test hint's id (key).
Expand All @@ -51,7 +51,7 @@ public class TestHint
* @param id - The test hint's id (key) which identifies a hint in the app's
* scope.
*/
public TestHint(AppiumDriver<MobileElement> driver, String id)
public TestHint(AppiumDriver driver, String id)
{
this.driver = driver;
this.id = id;
Expand All @@ -67,18 +67,18 @@ public void click()
}

/**
* Finds the underlying {@link MobileElement} for this {@link TestHint}
* Finds the underlying {@link WebElement} for this {@link TestHint}
* instance.
*
* @return {@link MobileElement}
* @throws NoSuchElementException if {@link MobileElement} could not be
* @return {@link WebElement}
* @throws NoSuchElementException if {@link WebElement} could not be
* found on the current screen.
*/
private MobileElement getElement()
private WebElement getElement()
{
return useAccessibilityForId()
? driver.findElementByAccessibilityId(id)
: driver.findElementById(id);
? driver.findElement(AppiumBy.accessibilityId(id))
: driver.findElement(By.ById.name(id));
}

/**
Expand Down Expand Up @@ -107,7 +107,8 @@ public String getValue()
*/
private boolean useAccessibilityForId()
{
Platform driversPlatform = driver.getCapabilities().getPlatform();
Platform driversPlatform
= Platform.fromString((String)driver.getCapabilities().getCapability("platformName"));

// FIXME This looks like a bug, but I don't want to deal with this right
// now.
Expand Down
Loading

0 comments on commit 90938fb

Please sign in to comment.