每次编译代码时,我都会得到“找不到符号”。但是,当我对项目进行重建然后编译时,它可以正常工作。不知道为什么会这样,我认为这是由于BSLocal上的导入。
extension ViewController: ARSCNViewDelegate {
func renderer(_ renderer: SCNSceneRenderer, didSimulatePhysicsAtTime time: TimeInterval) {
bowlingBall.removeBowlingBallWhenZPositionIsReached()
}
}
func removeBowlingBallWhenZPositionIsReached() {
guard let bowlingBallNode = bowlingBallNode else {return}
let bowlingBallPosition = bowlingBallNode.presentation.worldPosition
let zPositionOfBowlingBall = Int(bowlingBallPosition.z)
if zPositionOfBowlingBall > -7 {
performFadeOutOnBowlingBallWith(duration: 2.0)
}
}
这是TestBase.java类
"C:\Program Files\Java\jdk1.8.0_201\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\njayanthy\Desktop\WPS\BrowserStack "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\lib\idea_rt.jar=65122:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.2.4 clean compile package install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building BrowserStack 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ BrowserStack ---
[INFO] Deleting C:\Users\njayanthy\Desktop\WPS\BrowserStack\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BrowserStack ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ BrowserStack ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ BrowserStack ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ BrowserStack ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ BrowserStack ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ BrowserStack ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 2 source files to C:\Users\njayanthy\Desktop\WPS\BrowserStack\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[29,31] cannot find symbol
symbol: class BSLocal
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,19] cannot find symbol
symbol: class BSLocal
location: class com.mtrustcompany.browserstack.TestBase
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,37] cannot find symbol
symbol: variable BSLocal
location: class com.mtrustcompany.browserstack.TestBase
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[38,28] cannot find symbol
symbol: method getClass()
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.625 s
[INFO] Finished at: 2019-04-24T09:45:19-05:00
[INFO] Final Memory: 21M/538M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project BrowserStack: Compilation failure: Compilation failure:
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[29,31] cannot find symbol
[ERROR] symbol: class BSLocal
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,19] cannot find symbol
[ERROR] symbol: class BSLocal
[ERROR] location: class com.mtrustcompany.browserstack.TestBase
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[31,37] cannot find symbol
[ERROR] symbol: variable BSLocal
[ERROR] location: class com.mtrustcompany.browserstack.TestBase
[ERROR] /C:/Users/njayanthy/Desktop/WPS/BrowserStack/src/test/java/com/mtrustcompany/browserstack/TestBase.java:[38,28] cannot find symbol
[ERROR] symbol: method getClass()
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我不明白为什么会发生这种情况,以及在运行编译时没有任何问题的ide手动项目中发生了什么?
package com.mtrustcompany.browserstack;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.DataProvider;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.UnexpectedException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;
public class TestBase extends BSLocal {
public static BSLocal bsLocal = BSLocal.getInstance();
static URL serverUrl;
public WebDriver getWebDriver() {
return webDriver.get();
}
String className = this.getClass().getSimpleName();
static {
try {
;
serverUrl = new URL(String.format("http://%s:%s@%s/wd/hub", bsLocal.username, bsLocal.accessKey, bsLocal.server));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
/**
* ThreadLocal variable which contains the {@link WebDriver} instance which is used to perform browser interactions with.
*/
private ThreadLocal<WebDriver> webDriver = new ThreadLocal<WebDriver>();
/**
* DataProvider that explicitly sets the browser combinations to be used.
*
* @param testMethod
* @return Two dimensional array of objects with browser, version, and platform information
*/
@DataProvider(name = "browsers", parallel = true)
public static Object[][] sauceBrowserDataProvider(Method testMethod) {
return new Object[][]{
new Object[]{"firefox", "65.0", "Windows 10"},
new Object[]{"chrome", "70", "windows 10"},
};
}
/**
* @return the {@link WebDriver} for the current thread
*/
protected void createDriver(String browser, String version, String os, String methodName)
throws MalformedURLException, UnexpectedException {
Calendar now = Calendar.getInstance();
int year = now.get(Calendar.YEAR);
int month = now.get(Calendar.MONTH) + 1; // Note: zero based!
int day = now.get(Calendar.DAY_OF_MONTH);
Calendar c = Calendar.getInstance();
c.set(year, month - 1, day, 0, 0);
SimpleDateFormat format = new SimpleDateFormat("MMM dd,yyyy hh");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("build", String.format("%s %s", className, format.format(c.getTime())));
capabilities.setCapability(CapabilityType.BROWSER_NAME, browser);
capabilities.setCapability(CapabilityType.VERSION, version);
capabilities.setCapability("name", methodName);
capabilities.setCapability("browserstack.local", "true");
webDriver.set(new RemoteWebDriver(
serverUrl,
capabilities));
}
@AfterTest
public void done() {
bsLocal.stop();
}
@AfterSuite
public void mailTestReport() {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("", "");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("jayanthymohit6@gmail.com"));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(""));
message.setSubject(String.format("%s %s", className, new Date()));
BodyPart messageBodyPart1 = new MimeBodyPart();
messageBodyPart1.setText("Test Results");
MimeBodyPart messageBodyPart2 = new MimeBodyPart();
String filename = "C:\\Users\\njayanthy\\Desktop\\WPS\\BrowserStack\\test-output\\emailable-report.html";
DataSource source = new FileDataSource(filename);
messageBodyPart2.setDataHandler(new DataHandler(source));
messageBodyPart2.setFileName(filename);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart2);
multipart.addBodyPart(messageBodyPart1);
message.setContent(multipart);
Transport.send(message);
System.out.println("=====Email Sent=====");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
}
http://maven.apache.org/xsd/maven-4.0.0.xsd“> 4.0.0
<?xml version="1.0" encoding="UTF-8"?>