can someone, please, help, in following case:
Found element with following css selector (there is a list of charts, where only one chart has mark with "Current Day" text on top of it).
'div[id*="view-panel"] div.bar_chart g.bar_chart__now > text'
Based on that element, want to find another element (which is on found chart - its bottom), which displays name of the day (i.e "Friday"). Tried with following code:
cy.get('div[id*="view-panel"] div.bar_chart g.bar_chart__now > text').as('currentDay');
cy.get('#ccurrentDay').find('..').find('..').find('g.bar_chart__xaxis text');
Whole css selector for second element (for second code line above), looks:
'div[id*="view-panel"] div.bar_chart g.bar_chart__xaxis text'
What I tried to achieve is after first found element, go two steps back and find day name of chart bottom, but what I only get is an error:
CypressError: Timed out retrying: Expected to find element: ‘…’, but never found it.
What I am doing incorrect in above attempt to concatenate finding element? Thank you in advance
You should use Within command
cy.get('div[id*="view-panel"] div.bar_chart g.bar_chart__now > text')
.within(()=>{
cy.get('g.bar_chart__xaxis text')
})
Related
I am trying to get xpath by index and i am not making an progress. protractor says "that the element has more than one element is found for locator choosing the 1st one". however I want to make sure that the 1st one is selected intentionally screen shot below:
My code: that is not working:
I tried the following site nothing works:
https://devhints.io/xpath
xpath get element by index
Any help would be appreciated.
var payroll = element.all(by.xpath('//*[text()="Payroll"]')).first();
<div class="inline-check">
span class="ic-check" style="display: inline;">
Above is sample of the HTML which i am trying to find using any type of locater. It is text box which accept numbers and then shows a green tick mark that the input is accepted. Element style ="display: none;" turn to inline in HTML but when tried to look through xpath it is always visible like above.
I have tried finding the element using xpath and getting size of it and verify if it come as True or False.
but as the element is always present it passes even if the green tick is not displayed.
What technique should be used to find such elements.
Have you tried using the isDisplayed() method from WebElement https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebElement.html#isDisplayed-- ? It's basically a built in function that checks the style attribute.
So you could try doing something like this:
WebElement checkmark = driver.findElement(By.className("ic-check"));
assertTrue(checkmark.isDisplayed());
Hope this helps.
My main mission: Is to get the text of the next and the previous objects to the chosen object - To display the image (and its titles) Previous & Next.
Before that I have a problem: to get text of a selected object, from an index to a variable.
The problem: Every time I pick a random object, the variable does not change but the text is added to the existing text in the index.
I made a DEMO, would appreciate your help.
$(document).ready(function hintProject(){
$('#nextProject, #prevProject').click(function(){
subtitle = null;
subtitle = $('#client-sub.active').justtext();
$('#next_target_title').text(subtitle);
alert (' text::: ' + subtitle );
});
});
It looks like jQuery simply can't find the objects you're specifying. I don't think the problem is with the snippet in the question. I think the problem is with your document ready function.
To debug, try simplifying your problem by cutting out all of the additional complexity of the setup script and just set up an HTML page that is in the state you want. It's much easier to understand 1 problem than 2 or more.
Also, try simplifying how you're specifying an active item: a single class on the portfolio item would make your life easier. Then you can specify css and such based on the parent instead of adding multiple classes to multiple things inside the each portfolio item.
enter code hereI am having a little problem with jquery.empty().
I have some Html Divs which look like below:
<div id="Description_Error" class="ui-helper-hidden errorMessage"></div>
<div id="Order_Error" class="ui-helper-hidden errorMessage"></div>
<div id="ColorHex_Error" class="ui-helper-hidden errorMessage"></div>
These Divs get filled up at run time with some Uls and Lis. They are basically used to show the errors. Now I am wiping out all the errors that it was showing before I do a POST.
I use
$('ui-helper-hidden errorMessage').empty();
for that. Now, i fit is showing all three errors then it will wipe out two bue leave one. If it is showing only one error at the time then it will not be removed at all. I am not sure why class selection decides to leave one element behind all the times. Anyway, i tried to replicate the same behavior on Jsfiddler but it works fine. I am not able to find a clue on what might be wrong on my code. Any suggestions?
here is the fiddler link which works all file. Just my HTMl code does not work fine:
http://jsfiddle.net/g55Rs/3/
You are neither refering to a class nore an element identifier.
$('ui-helper-hidden errorMessage').empty();
To reference classes use the . and to use element identifiers use #.
In your case this will empty all the divs:
// Selecting all elements which have both classes
$('.ui-helper-hidden.errorMessage').empty();
DEMO - Empty all element which have both classes
I also added some element which only have one or the other class in the DEMO to show that they are not effected.
First of all this is how the script works: jsfiddle
The 'searchList' setting specifies the content that will be searched. In this case it is searchable tr. Finally, the 'searchItem' setting allows to dive in and specify an individual element to search. In this case, I use 'td'.
In this fiddle
I have a list of thumbnail images with some informations, what I want to do is to be able to search for "something" and then to show the image and the text related to that specific thumbnail.
Hope you understand what I'm trying to achieve.
Out on a limb, but your selector for searchList looks wrong:
'searchList' : '.imgscontainer portfolio-v6-items ',
Surely that second class should have a dot before it, and they're on the same element, so no space:
class="imgscontainer portfolio-v6-items"