Found problems related to java

Изучаю Аппиум. Столкнулся с такой проблемой: в IDEA отобажает Related problem над переменной, которую я использую для сохранения части ID. Дело в том, что первая часть ID элемента состоит из appPackagе, а вторая -это id элемента на экране аппиум. Мне нужно, чтоб первая часть была изменяемая. Я ее поместил в String переменную. И во всех классах моей программы это работате, кроме одного.

 public class BaseSetup < //обьявление переменных private DesiredCapabilities cb =new DesiredCapabilities(); private static AndroidDriver ad =null; private String port = "4723"; private String server = "127.0.0.1"; **//тут я объявляю эту переменную, которая имеет значение для appPackage** protected String myapp = "com.covantex.mediker"; @BeforeClass //публичный класс для вызова приватного класса public void setUp() throws MalformedURLException < initDriver(); >/* метод который будет возвращать драйвер для передачи его следующим страницам при переходе на другие активити а так же получения драйвера в пределах текущего активити */ public AndroidDriver getDriver() < return ad; >//приватный класс с данными для запуска сессии private void initDriver() throws MalformedURLException < //создание экземпляра класа для передачи парамеров запуска приложения на устройстве DesiredCapabilities ds =new DesiredCapabilities(); ds.setCapability(MobileCapabilityType.DEVICE_NAME,"374c3291"); ds.setCapability("platformName", "Android"); ds.setCapability( "appPackage", myapp); ds.setCapability( "appActivity", "com.meetMyDoc.ui.activity.LoginActivity"); ds.setCapability("noReset",true ); String url = "http://"+server+":"+port+"/wd/hub"; //инициализация андроид райвера + ексепшин для отлова ошибок try< System.out.println("Драйвер проинициализирован с такими данными: " + url); ad = new AndroidDriver(new URL(url), ds); >catch (NullPointerException|MalformedURLException ex) < throw new RuntimeException("Андроид драйвер не может быть проинициализирован :("); >System.out.println("Не инициализирован: " +ad); > > 
// наследование от BaseSetup public class Driver extends BaseSetup < protected AndroidDriver ad; //это конструктор, где происходит инициализация драйвера родителя protected Driver()< this.ad = super.getDriver(); >> 

От драйвера наследуется MainPage, в котором я тоже использую переменную myapp как части id для нахождения элемента на экране.

public class MainPage extends Driver < public void clickBtn() throws InterruptedException < Thread.sleep(3000); MobileElement el3 = (MobileElement) ad.findElementById(myapp + ":id/btnLogin"); el3.click(); >public void sendCredentials() throws InterruptedException < Thread.sleep(2500); //тут работает MobileElement el1 = (MobileElement) ad.findElementById( myapp + ":id/etUserName"); el1.sendKeys("admin"); // и тут работает MobileElement el2 = (MobileElement) ad.findElementById( myapp + ":id/etPassword"); el2.sendKeys("admin"); >

Дальше я использую класс ScreenFormPF. Именно в нем я пытаюсь использовать myapp переменную. Именно в аннотации. И тут эта переменная подчеркивается красным. И пишет Related problem.

 public class ScreenFormPF extends MainPage < public ScreenFormPF( )< PageFactory.initElements(new AppiumFieldDecorator(ad), this); >// тут уже не работает и подчеркивает красным @AndroidFindBy(id = "com.covantex.mediker:id/etUserName") private AndroidElement login; // тут тоже не работает @AndroidFindBy(id = "com.covantex.mediker:id/etPassword") private AndroidElement password; > 

Источник

Читайте также:  Опасно ли содержать питона дома

In this page you will see the common java related problems you face during your day to day activity. We are listing out all common problems and its solutions here. If you have come across any java related issues, please let us know, we will update here. It will be very helpful for others to resolve it very quickly.

Java problems and solutions

  1. Unable to install Java 7 in Eclipse on Mac — Java 7 Mac OS issues
  2. How to change Java (JVM) version in Mac OS? — Java version Mac OS issues
  3. SunCertPathBuilderException: Unable To Find Valid Certification Path To Requested Target
  4. How to merge two jssecacerts files? — Merge key store files
  5. How to write Micro-Benchmark for java Hotspot?
  6. servlet-api-2.5.jar — jar not loaded — tomcat error
  7. How to exclude property files in a jar using Maven
  8. ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
  9. CGLIB is required to process @Configuration classes
  10. Git command to list conflicted files
  11. Where is default localhost folder in Mac OSX?
  12. How to edit hosts file on Mac OSX
  13. How to set up java version in Maven based projects?
  14. How to split a string by new line character in java?
  15. How to configure Spring Boot without the parent POM (spring-boot-starter-parent)?
  16. My Spring boot application is not scaning my components (controllers)
  17. How to download a file in Spring RestController?
  18. How to get convert excel HSSFWorkbook (workbook) into byte array?
  19. How to add Oracle JDBC driver in your Maven local repository
  20. How to add jar file in your Maven local repository using command line?
  21. How to add default value to Spring @Value annotation?
  22. How to route Apache ProxyPass configuration through another proxy server? (Proxy to proxy)
  23. How to disable Maven unit test?
Читайте также:  Html tags in script tag

ServletOutputStream: ServletResponse.getOutputStream() returns a ServletOutputStream suitable for writing binary data in the response. The servlet container does not encode the binary data, it sends the raw data as it is.

PrintWriter: ServletResponse.getWriter() returns PrintWriter object which sends character text to the client. The PrintWriter uses the character encoding returned by getCharacterEncoding(). If the response’s character encoding has not been specified then it does default character encoding.

About Author

I’m Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected] .

Most Visited Pages

Источник

Error in the 2maven project startup process

Solution:

error prompt

 Source option 5 is no longer supported. Please use 7 or higher. The target option 5 is no longer supported. Please use 7 or higher. 

    org.apache.tomcat.maven tomcat7-maven-plugin 2.2 8888   org.apache.maven.plugins maven-compiler-plugin 1.8 1.8 UTF-8     

3. Console News: Property ‘Datasource’ Is Required

Java.lang.illegalargumentException: Property 'DataSource' Is Required is that DataSource is required Dataource is empty when using DAO. Check the JDBCUTILS tool class, find that the class loader loads the druid.properties file, then use the class loader if it is obtained from classpath. So don't need to be added / 

4. Console notes: org.springframework.dao.emptyResultDataAccessException: IncorRect Result Size: Expected 1, Actual 0

Error message org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0 at org.springframework.dao.support.DataAccessUtils.requiredSingleResult(DataAccessUtils.java:71) at org.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:812) 

plan
queryForObject is not recorded when there is no record, and this exception will not throw this exception for the type of Query () LIST. The solution is to capture this exception and then return NULL in catch. The modification code is as follows:

 @Override public User findByUsername(String username) < User user=null; try< // 1. Define SQL String sql="select * from tab_user where username= ?"; // 2. Execute SQL user= template.queryForObject(sql, new BeanPropertyRowMapper(User.class), username); >catch (Exception e) < return null; >> 

5.java.lang.NoSuchMethodException

problem java.lang.NoSuchMethodException: cn.itcast.travel.web.servlet.UserServlet.add(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) at java.base/java.lang.Class.getMethod(Class.java:2113) at cn.itcast.travel.web.servlet.BaseServlet.service(BaseServlet.java:31) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at cn.itcast.travel.web.filter.CharchaterFilter.doFilter(CharchaterFilter.java:30) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:835) Request path / travel // user / find Method name FIND [email protected] java.lang.NoSuchMethodException: cn.itcast.travel.web.servlet.UserServlet.find(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) at java.base/java.lang.Class.getMethod(Class.java:2113) at cn.itcast.travel.web.servlet.BaseServlet.service(BaseServlet.java:31) 

Solution 1

Solution 2
Change method for modifier for public

 public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException < System.out.Println ("UserServlet's Add method . "); >public void find(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

6.idea console Chinese garbled solution: -dfile.encoding = GB2312

7. Solve Chinese parameters in Tomcat7 garbled

 rname=new String(rname.getBytes("iso-8859-1"),"utf-8"); 

8. Interellij IDEA Settings a single line of travel Release Remove extra spaces

Question: When the Java code uses shortcuts «Ctrl + /» to add a line comment, it is found to have extra spaces:


Solve:
Open IDEA: File> Settings> Editor> Code Style> Java> Checking Use Tab Character
Indicates that Tab indent does not use a space to use tab, and the above excess space problem occurs if you use spaces.
Finally, formatted the following code: «Ctrl + Alt + L»

problem:

Solution:

problem:

solution:

9mAven Since his agreement is greater than the configuration, we can experience the profile we write, unable to be exported or taken effect,

     src/main/java **/*.xml **/*.properties  false  src/main/resources **/*.xml **/*.properties  false    
Default is false true This configuration means that the placeholder in the specified properties file is filtered, the placeholder is the form of $ , and Maven will automatically read the configuration file, then resolve the placeholder, use the above POM file. Defined attributes replace -> 

Источник

Оцените статью