logo
down
shadow

Any selector using * failed in my case


Any selector using * failed in my case

By : Joshua
Date : November 22 2020, 03:03 PM
Does that help , To access the classes containing a specific text at the beggining:
code :
$("[class^=cd]")
$("[class$=cd]")


Share : facebook icon twitter icon
use jquery selector with variable failed in my case

use jquery selector with variable failed in my case


By : user3430673
Date : March 29 2020, 07:55 AM
Any of those help adeneo and Vijay are both right on for how to do what you asked.
One thing I would mention is that, IMO, using incremental ids (item1, item2, etc...) is bad practice and you can end up with some pretty messy code.
code :
var x = 1
$('.items:eq('+x+') .list').remove();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="items">
  <ul class="list">
    <li>list 1</li>
  </ul>
 </div>
<div class="items">
  <ul class="list">
    <li>list 2</li>
  </ul>
 </div>
<div class="items">
  <ul class="list">
    <li>list 3</li>
  </ul>
 </div>
<div class="items">
  <ul class="list">
    <li>list 4</li>
  </ul>
 </div>
<div class="items">
  <ul class="list">
    <li>list 5</li>
  </ul>
 </div>
Failed to execute query selector on document, id is not a valid selector

Failed to execute query selector on document, id is not a valid selector


By : nielsholmgaard
Date : March 29 2020, 07:55 AM
help you fix your problem You might find jQuery easier, and it's automatically cross-browser (and faster to type!) Since it's tagged on your question, here is the jQuery solution:
jsFiddle Demo
code :
$('[id^=edit_]').click(function(){
    var id = this.id.split('_')[1];
    $('#'+id).addClass('hidden');
    $('#edit_'+id).addClass('hidden');

    $('#save_'+id).removeClass('hidden');  
    $('#editable_'+id).removeClass('hidden');  
});

$('[id^=save_]').click(function(){
    var id = this.id.split('_')[1];
    $('#'+id).removeClass('hidden');
    $('#edit_'+id).removeClass('hidden');

    $('#save_'+id).addClass('hidden');  
    $('#editable_'+id).addClass('hidden');  
});
Rerun whole class in case of failed test case using TestNG

Rerun whole class in case of failed test case using TestNG


By : Shatrong Ever
Date : November 05 2020, 04:01 AM
it fixes the issue Finally found a workaround to rerun the whole class. I would call it a workaround since technically TestNG does not provide a way to re-execute @BeforeTest in case a failure occurs at any point of time.
The best possible method I found was to have no @BeforeTest section and have just one @Test section and have all Test cases as functions which would be called within the single @Test defined. So in case a failure occured at any point of time, the @Test would be recalled which contains all the functions in the order required including setting up the capabilities. The retry logic reruns the entire @Test section as soon as a failure is observed.
code :
package <yourpackagename>;

<import required packages>

public class Home {
    private AppiumDriver<?> driver;
    private static final String url = "http://0.0.0.0:4723/wd/hub";

    <define your variables>

    @Parameters({"deviceOS", "DSN"})
    @BeforeTest
    public void setUp(String deviceOS, String DSN) throws InterruptedException, MalformedURLException, ParseException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("deviceName", "FireTVStick");
        capabilities.setCapability("platformVersion", deviceOS);
        capabilities.setCapability("udid", DSN);
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("noReset", true);
        capabilities.setCapability("fullReset", false);
        capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 1200);
        capabilities.setCapability("appPackage", "<your app package>");
        capabilities.setCapability("appActivity", "<your launcher activity>");
        driver = new AndroidDriver<>(new URL(url), capabilities);
        driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
        //End of Launch Code

        System.out.println("-Testing Home Section-");
    }   


    @Parameters({"DSN"})
    @Test
    public void Test1_VideoPlaybackVerification(String DSN) throws InterruptedException, ParseException{

        //Video playback verification code starts
        .
        .
        //End of code for Video playback verification
    }


    @Test //Test Case for Pause verification
    public void Test2_PauseVerification() throws InterruptedException, ParseException{
        //Video pause verification code starts
        .
        .
        //End of code for Video pause verification
    }

    @AfterTest
    public void End() {
        driver.quit();
    }
}
package <yourpackagename>;

<import required packages>

@Listeners(MyTestListenerAdapter.class)
public class Home {
    private AppiumDriver<?> driver;

    <define your variables>

    public void setUp(String port, String deviceOS, String DSN, String deviceName) throws InterruptedException, MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("platformVersion", deviceOS);
        capabilities.setCapability("deviceName", deviceName);
        capabilities.setCapability("udid", DSN);
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("noReset", true);
        capabilities.setCapability("fullReset", false);
        capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 1200);
        capabilities.setCapability("appPackage", "<your app package>");
        capabilities.setCapability("appActivity", "<your launcher activity>");
        final String url = "http://127.0.0.1:"+port+"/wd/hub";
        driver = new AndroidDriver<>(new URL(url), capabilities);
        driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
    }

    public void HomeVerification(String DSN, String deviceName) throws InterruptedException, ParseException
    {
        System.out.println(deviceName+": Testing Home Section-");

        <--Your code to perform any additional task before execution-->
    }

    public void Test1_VideoPlaybackVerification(String DSN, String deviceName) throws InterruptedException, ParseException
    {       
        //Video playback verification code starts
        .
        .
        //End of code for Video playback verification
    }

    public void Test2_PauseVerification(String deviceName) throws InterruptedException, ParseException
    {

        //Video pause verification code starts
        .
        .
        //End of code for Video pause verification
    }

    @Parameters({"port", "deviceOS", "DSN", "deviceName"})
    @Test (retryAnalyzer = Retry.class)
    public void TestRun(String port, String deviceOS, String DSN, String deviceName) throws InterruptedException, ParseException, MalformedURLException {

        try {
            setUp(port, deviceOS, DSN, deviceName);
            HomeVerification(DSN, deviceName);
            Test1_VideoPlaybackVerification(DSN, deviceName);
            Test2_PauseVerification(deviceName);
        } catch (WebDriverException e) {
            // TODO Auto-generated catch block
            Reporter.log(deviceName+": Error observed while executing script!", true);
            Assert.assertTrue(false); //Fails the test case
        }

    }

    @AfterTest
    public void End() {
        driver.quit();
    }
}
When I used guard case in sum_time method one test case failed, any suggestions?

When I used guard case in sum_time method one test case failed, any suggestions?


By : user2989726
Date : March 29 2020, 07:55 AM
Any of those help Firstly, I would recommend against polluting the core Ruby class Time. The needed methods could be housed in a custom class or possibly defined at the level of main (as I have done below).
Nor would I make use of the classes Time or DateTime. It's easier to just deal with strings. Begin by constructing a regular expression that will be used to determine if each time string is valid.
code :
VALID_TIME = /
             \A        # match beginning of string
             (?:       # begin non-capture of group
               0?\d    # optionally match a zero followed by a digit
               |       # or
               1\d     # match 1 followed by a digit
               |       # or
               2[0-3]  # match 2 followed by a digit 0, 1, 2 or 3
             )         # end non-capture group
             (?:       # begin a non-capture group
               :       # match a colon
               [0-5]   # match a digit 0, 1, 2, 3, 4 or 5
               \d      # match a digit
             )         # end non-capture group
             {2}       # execute the previous non-capture group twice
             /x        # free-spacing regex-definition mode
/\A(?:0?\d|1\d|2[0-3])(?::[0-5]\d){2}/
def total_times(*time_strings)
  seconds    = tot_seconds(*time_strings)
  days, hrs  = seconds.divmod(24*3600)
  hrs,  mins = hrs.divmod(3600)
  mins, secs = mins.divmod(60)
  [days, hrs, mins, secs]
end
def tot_seconds(*time_strings)
  time_strings.sum { |time_str| time_str_to_seconds(time_str) }
end
def time_str_to_seconds(time_str)
  raise ArgumentError, "'#{time_str}' is an invalid 24-hour time value" unless
    time_str.match?(VALID_TIME)
  [3600, 60, 1].zip(time_str.split(':')).
                reduce(0) { |tot,(n,s)| tot + n*s.to_i }
end
time_str = "9:35:08"
time_str.match?(VALID_TIME)
  #=> true
a = time_str.split(':')
  #=> ["9", "35", "08"] 
b = [3600, 60, 1].zip(a)
  #=> [[3600, "9"], [60, "35"], [1, "08"]]
b.reduce(0) { |tot,(n,s)| tot + n*s.to_i }
  #=> 3600*9 + 60*35 + 1*8 => 34508
arr = total_times "2:33:41", "23:46:08"
  #=> [1, 2, 19, 49]
puts "%d day & %d:%2d:%2d" % arr
"1 day & 2:19:49"
days, hrs, mins, secs = total_times "2:33:41", "23:46:08"
tot_secs =  2*3600 + 33*60 + 41 +
           23*3600 + 46*60 +  8
  #=> 94789 
days, hrs  = tot_secs.divmod(24*3600)
  #=> [1, 8389] 
hrs, mins  = hrs.divmod(3600)
  #=> [2, 1189] 
mins, secs = mins.divmod(60)
  #=> [19, 49] 
[days, hrs, mins, secs] 
  #=> [1, 2, 19, 49] 
total_times "11:23:07", "22:53:45", "0:23:23", "23:45:56"
  #=> [2, 10, 26, 11]
total_times "24:01:10", "10:30:50"
  #=> ArgumentError ('24:01:10' is an invalid 24-hour time value)
time_str = "9:35:08"
hr, min, sec = time_str.split(':').map(&:to_i)
  #=> [9, 35, 8] 
(0..23).cover?(hr) && (0..59).cover?(min) && (0..59).cover?(sec)
  #=> true
switch case isn't true than also its executing case which is inside the failed one

switch case isn't true than also its executing case which is inside the failed one


By : Luis Ag
Date : March 29 2020, 07:55 AM
like below fixes the issue After switch(2), it will jump immediately to the case 2 label. The fact that it is within an if block contained within case 1 is irrelevant. case 2: effectively functions no differently from a goto label, so it will jump to it wherever it is. It is not true that case 1 is somehow being entered.
To clarify, properly indented it looks thus:
Related Posts Related Posts :
  • How to change add and remove active class in JavaScript
  • how to toggle a specific div in javascript
  • How to get all the values from multiple keys of an array of object?
  • jQuery bind() unbind() and on() and off()
  • regular expression to find DD Month YYYY from a string
  • How to upload files from web client (HTML/jQuery form) to your Dropbox folder
  • Backbone history and require.js issue
  • Confusion over Classical and Prototypal Inheritance Javascript
  • How to take screen shot of current webpage using Javascript/JQuery?
  • Store meridiem in a variable
  • class declared inside closure vs standard class without closure
  • javascript confirm box always return true
  • dynamically changing the size of font size based on text length using css and html
  • Node.js - Getting the host IP address while on Amazon EC2
  • Confusing CSS, can anyone explain please
  • How to install v8-profiler on Windows 8 (64 bit) using npm?
  • Resolve promise based on another promise
  • google maps adding overlay layer above UI and markers
  • Style specific letter?
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org