Jump to content


  • Posts

  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

26,063 profile views

newcoder1010's Achievements

Invested Member

Invested Member (3/7)



  1. Hello, <input class="js-text-full text-full form-text form-element form-element--type-text form-element--api-textfield" data-drupal-selector="edit-field-other-features-0-value" type="text" id="edit-field-other-features-0-value" name="field_other_features[0][value]" value="Other features include: hot water, cooking stove, aircon, open kitchen, security system" size="60" maxlength="255" placeholder=""> CSS input { height:100px; background: green; vertical-align: top; } Tried below as well but it did not work. padding-top:0px https://ibb.co/Fwsmgj2 How can I vertically align all the input text fields to top?
  2. Hello, windows + php + xampp + mysql https://www.w3schools.com/php/php_mysql_connect.asp I am getting the error when I run the php script in terminal. <?php echo "<br> --- CREATE DB --- <br>"; $servername = ""; $username = "root"; $password = "password"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connected successfully"; // Create database $sql = "CREATE DATABASE myDB"; if ($conn->query($sql) === TRUE) { echo "Database created successfully"; } else { echo "Error creating database: " . $conn->error; } When I run the script on browser, I get this message --- CREATE DB ---Connected successfullyDatabase created successfully But when I run the script in terminal, I get an error Stack trace: #0 {main} thrown in C:\xampp\w3schoolsPhp\httdocs\database-create.php on line 16 PS C:\xampp\w3schoolsPhp\httdocs> php database-create.php <br> --- CREATE DB --- <br>PHP Fatal error: Uncaught Error: Class "mysqli" not found in C:\xampp\w3schoolsPhp\httdocs\database-create.php:16 Stack trace: #0 {main} thrown in C:\xampp\w3schoolsPhp\httdocs\database-create.php on line 16 php.ini /configure --with-mysqli=/path/to/mysql_config extension=bz2 extension=curl ;extension=ffi ;extension=ftp extension=fileinfo ;extension=gd extension=gettext ;extension=gmp ;extension=intl ;extension=imap ;extension=ldap extension=mbstring extension=exif ; Must be after mbstring as it depends on it extension=mysqli ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client ;extension=oci8_19 ; Use with Oracle Database 19 Instant Client ;extension=odbc ;extension=openssl ;extension=pdo_firebird extension=pdo_mysql ;extension=pdo_oci ;extension=pdo_odbc ;extension=pdo_pgsql extension=pdo_sqlite ;extension=pgsql ;extension=shmop extension=php_mysql.dll
  3. Hello, Var will change dynamically. It could be one of the below in each iteration. String var = " My name is <name="name of the person" country = "some texts" >"; String var = " My name is <name="name of the person" city = "some texts" >"; String var = " My name is <name="name of the person"country = "some texts" >"; // no space after double quotes String var = " My name is <name="name of the person"city = "some texts" >"; // no space after double quotes How can I search and return only the following string from above variables? name="name of the person" Thank you!
  4. Hello, <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> img { border-radius: 50%; } </style> </head> <body> <h2>Rounded Images</h2> <img src="/sites/default/files/2022-12/bg-house.png" alt="Avatar" style="width:200px"> </body> </html> Original image https://ibb.co/zH7HXfg Round image after styling. It looks oval shape. https://ibb.co/YpSBKw5 How can I round the image like this one in below? https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_rounded_images
  5. Hello, I would like to style a call now block like the one below Here is my HTML: <span class="glyphicon glyphicon-earphone"></span> <a href="tel:(000)926-4444" class="phone">Call Now!</a> It does not have to be exactly the same as the image. Something close to the image would be helpful. Thank you!
  6. I made some progress but not working yet. Its not reaching the block of code inside the loop LocalDateTime timeNow = java.time.LocalDateTime.now(); System.out.println( "timeNow "+ timeNow); LocalDateTime newtime = timeNow.plusMinutes(5); System.out.println( "newtime "+ newtime); Thread.sleep(5000); while(newtime.equals(timeNow)) { Thread.sleep(5000); timeNow = java.time.LocalDateTime.now(); System.out.println( "timeNow "+ timeNow); } System.out.println( "timeNow exited at "+ timeNow);
  7. Hello, I like to add 5 minutes to current system time. After adding 5 minutes to the current time, I like to have a loop which will keep checking until system time has changed to the new time. Lets say now is 11:50:01AM Add 5 minutes to current time. So new time would be 11:55:01AM I like to have a loop which will keep checking if system time is 11:55:01AM. If yes, exit the loop. I started working on it but I am not quit there yet. LocalDateTime timeNow; while(???) { Thread.sleep(6666); timeNow = java.time.LocalDateTime.now(); } Can you help?
  8. Hello, Base.java package JavaTestNG; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; public class Base { public int x; // Invoked once when I run the xml file @BeforeTest public void beforeTest() { x=9; } // invoked once for every class @BeforeClass public void beforeClass() { System.out.println("beforeClass"); } } Test1.java import org.testng.annotations.Test; public class Test1 extends Base{ @Test public void test1() { System.out.println("test 1"); System.out.println("x " + x); } } Test2.java import org.testng.annotations.Test; public class Test2 extends Base{ @Test public void test2_1() { System.out.println("test2_1"); System.out.println("x " + x); } } Test3.java import org.testng.annotations.Test; public class Test3 extends Base{ @Test public void test3_1() { System.out.println("test3_1"); System.out.println("x " + x); } } XML: Running the xml file <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"> <suite name="test"> <test name="Test1"> <classes> <class name="JavaTestNG.Test1" /> <class name="JavaTestNG.Test2" /> </classes> </test> <test name="Test2"> <classes> <class name="JavaTestNG.Test3" /> </classes> </test> </suite> Console [RemoteTestNG] detected TestNG version 7.4.0 beforeClass test 1 x 9 beforeClass test2_1 x 0 beforeClass test3_1 x 9 --- As you can see, I am getting x 0 for the second test. I am not sure why x = 0 for the second test. Instead, I was expecting to have the value of 9. Can you please help?
  9. Hello, First Test: public class FirstTest extends GridSessionBase { @Test public void test1() { System.out.println("First test"); printSessionThreadID(); } } Second Test: public class SecondTest extends GridSessionBase{ @Test public void test1() { System.out.println("Second test"); printSessionThreadID(); } } Base: public class GridSessionBase{ WebDriver driver; // invoked once before executing each @Test method @BeforeMethod public void beforeMethod(Method method) { System.setProperty("webdriver.chrome.driver", "Automation_Tools\\ChromeDriver\\chromedriver.exe"); driver = new ChromeDriver(); System.out.println("beforeMethod"); SessionId s = ((RemoteWebDriver) driver).getSessionId(); System.out.println("Before method session ID: " + s); long id = Thread.currentThread().getId(); System.out.println("Before method thread ID: " + id); } // all the tests are calling this method. public synchronized void printSessionThreadID() { System.out.println("printSessionThreadID"); SessionId s = ((RemoteWebDriver) driver).getSessionId(); System.out.println("Session ID: " + s); long id = Thread.currentThread().getId(); System.out.println("Thread ID: " + id); // if session id and thread id match // if() { // // print class name and test method name of the caller // } } } XML file to run the tests in parallel: Below I have two <test> tags. It means all the TestNG methods listed in each <test> tag will run in the same thread. Test1 will run in one thread and Test2 will run in another thread. Both <test> tags will run in parallel. <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"> <suite name="Access Regression Suite" parallel="tests"> <test name="Test1"> <classes> <class name="GridSessionJava.FirstTest"/> </classes> </test> <test name="Test2"> <classes> <class name="GridSessionJava.FirstTest" /> <class name="GridSessionJava.SecondTest" /> </classes> </test> </suite> When I run xml file, here is the output: printSessionThreadID() is being called three times. In printSessionThreadID() method, I like to know which test is calling this method. How do I write if statement in printSessionThreadID() method to check if session ID and thread ID match(or just matching thread ID) and print a message afterward?
  10. To summerize, I am setting the logger before every test method. Then trying to get the logger from another class.
  11. <!-- https://mvnrepository.com/artifact/com.relevantcodes/extentreports --> <dependency> <groupId>com.relevantcodes</groupId> <artifactId>extentreports</artifactId> <version>2.41.2</version> </dependency> BaseTest public class BaseTest extends Base{ public static ExtentReports reporter; public ExtentTest loggerParent = null; // invoked once before I run one or more tests @BeforeSuite public void initializeReport(){ reporter = new ExtentReports("ExtentReport6.html", true, DisplayOrder.OLDEST_FIRST); } // invoked before every @Test method @BeforeMethod public synchronized void beforeMethod(Method method) { System.out.println("beforeMethod"); logger = reporter.startTest(method.getName()); loggerParent.appendChild(logger); setLogger(logger); logger.log(LogStatus.INFO, "before method"); } @BeforeClass public void beforeClass() throws MalformedURLException { ITestResult itr = Reporter.getCurrentTestResult(); String className = itr.getInstance().getClass().getName(); loggerParent = reporter.startTest(className); loggerParent.log(LogStatus.INFO, "Before class"); } @AfterSuite public void afterSuite() { reporter.flush(); } } Base package Base; import com.relevantcodes.extentreports.ExtentTest; public class Base { public ExtentTest logger = null; public void setLogger(ExtentTest logger1) { this.logger = logger1; } public synchronized ExtentTest getLogger() { return logger; } } DataDriven public class DataDriven extends Base{ public synchronized void launchExcelFile(String fileNameWithExtension, String sheetName) { logger.log(LogStatus.INFO, "launch excel"); }} @Test public class CreateAccount extends BaseTest2 { @Test public void test1() { logger.log(LogStatus.INFO, "create account test8"); DataDriven dataDriven = new DataDriven(); dataDriven.launchExcelFile("TestData.xls", "profiles"); }} Error when I run the test: Error is from this line in DataDriven.java logger.log(LogStatus.INFO, "launch excel"); I spent all day but could not fix it yet. I am just not sure how to use the logger in DataDriven file. Thank you in advance!
  12. Thanks for your reply. I am trying to set name from one class and be able to get name from another class. As you can see, I have set name in @Test method from CreateAccount class . setName("Mike"); I am trying to get the same name from GetData class. How can I do it?
  13. Hello, public class Base { public String name = null; public String getName() { return name; } public void setName(String myName) { this.name = myName; } } GetData public class GetData extends Base{ public String GetMyData() { return getName(); } } Test: public class CreateAccount extends Base { @Test public void test1() { setName("Mike"); String name = getName(); System.out.println("get name: " + name); // get the value "Mike" GetData getData = new GetData(); name = getData.GetMyData(); System.out.println("get name: " + name); // get null } } Output: I expected to get "Mike" both cases but I am getting null second time. I could fix it by writing static but I am doing some parallel testing. How can I fix it without writing static? public static String name = null;
  14. Hello, Maven dependency: <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.4.0</version> </dependency> Main method public class HelloMain { private final static Logger log = LoggerFactory.getLogger(HelloMain.class); public static void main(String[] args) { log.info("hello"); } } When I run the program in IntelliJ, I get the error on the following line: private final static Logger log = LoggerFactory.getLogger(HelloMain.class); I fixed it by changing the dependency version: <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.3.0</version> </dependency> Java on my pc: C:\Users\sa>java -version java version "1.8.0_341" Java(TM) SE Runtime Environment (build 1.8.0_341-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode) Could you please explain me why I got the error first place? Why changing the version of logback fixed the problem? I am bit confused with java compiler, JDK, JRE, and Dependency version. If you could include an example, it would help. I am new to Spring framework. Thank you!
  • Create New...