Web element with same name and xpath under two elements in the navigation pane - python-3.x

I have 2 web elements with the same XPath and name but under the different navigation links. Both links point to the same page but with a different title. How should I access each of the links uniquely?
I am a beginner to python selenium programming

You have the answer in the question itself. You must try identifying the elements using title with combination of other attributes if they have unique titles.
PS: Please(always) add the code you have tried and the relevant(in this case HTML) required files/snippet which can help us understand and investigate better. Questions with enough information get faster replies :)

Related

Find Elements with dynamic id's and Xpaths's

I apologize if this is a duplicate of a question already but nothing I read seemed to do the trick.
I am trying to automate the process of adding my hours for my job. This entails using selenium to mimic the process I do to enter the hours for me.
The problem is, as I navigate through the process, I have run into an instance where one of the elements has a dynamic id and xpath (any maybe other things. I am not very proficient in HTML).
I need to select the "Day" button on the "View" drop down. The highlighted HTML corresponds to that button. I have already checked and both the ID and Xpath change every time I create a new session. I usually do the following to find my elements:
elem = driver.find_element_by_xpath('xpath')
Below is the xpath I currently see:
//*[#id="ab5378a9418345a2a57ad12f066127a6"]
To further complicate things, the xpath for the "Week" selection is the following:
//*[#id="741015164c5547fbb5403c03c46636d3"]
I tried to figure out how to use "contains" with the xpath but even so, the two are not different enough to differentiate by using "#id". The only constant thing and difference I see each time is that the
data-automation-label="Day"
is present on the day element and
data-automation-label="Week"
is present on the week element.
Does anyone have any experience finding the elements when a problem like such occurs? I am working in Python3.6 on a windows 7 computer.
Again, I apologize if this is a duplicate but I tried very hard to find an answer before coming here for help.
Thanks in advance!
You can use two of the below possible selectors
XPATH
//div[#data-automation-label="Day"]
CSS
div[data-automation-label="Day"]
When you use identifier your main focus should be how to find something that is unique to that object. And it really doesn't matter if it is name or id or what not. Use what you think would work the best. And here data-automation-label implies that itself

People listage in SharePoint page

i have an intranet (which is my main website) and a several sub-websites, which refers to the departments of the company. I need to add a list with people related to department of the current web-site. The list can be the same view of the SharePoint native search.
I find this component (Search Results), which i was able to add my criterias (like people which department is equals to "HR"), and i get the right results. However, i couldn't find an way to make the view similar to the results of the image above.
Somebody can help me? Thanks
Edit:
I've changed the configurations to use "People Item" display index. Firstly, i had to import a javascript file. Then, even though that i had the right results, the properties aren't filled in the fields of the display item (as is shown in the image below).

One custom display form for all the lists

Good day to you. I am newbie in SharePoint 2013 so please bear with me. I have created around 15 lists in my website each containing same columns but different data (they differ semantically).
I am aware that we can change the default view, edit and display form for each list by creating new form in SharePoint Designer 2013. This seems like a very bad approach as far as the maintenance is concerned. I know my lists are exactly the same so why do I have to create same 15 display forms for each of the lists?
Is there a way to create one custom Display form (may be in a central location, i don't know i am just thinking :P ) for all the lists? Is there a way to tell a list to use a specific display form? Any help will be highly appreciated. Thanks.
If i understand your question correctly, you have 15 lists with same set of columns. You want to change the display/look of the form. All 15 lists should have same look and feel right!! If yes, then why don't you try with some html, javascript solution. Since you are in sharepoint 2013, javascript support for solutions is very good like rest queries. You can use SPServices also.
If you want to to add data to the list whenever you click on the "New Item" link in the list then hijack this link such that it should navigate to your custom form. Pass your list name as query parameter. Whenever user is saving the form, get the list name from the query parameter and save the data to that list.
There could be another ways also to achieve the solution with html and javascript.
Useful links:
Microsoft, Microsoft, SPServices
Sam I think you can create a custom content type and create custom display form for your content type. Enable the content type in each of your lists so automatically this customized form would be available.
The advantage of this approach is that suppose if you need one more list after some time you can just add this content type and your form would be available into the new list as well.
The approach is explained in the link below.
http://blogs.msdn.com/b/varun_malhotra/archive/2009/06/06/define-custom-new-edit-display-forms-for-content-types.aspx
Check this one also
https://joshmccarty.com/2011/02/sharepoint-custom-list-with-custom-content-types-and-custom-display-forms/
Just wanted to write the solution which I implemented as it might help others as well. (Thanks Hiren and Mihir for your valuable inputs)
I had 15 lists and I was showing the data to the user using content search web part with custom display template. All of the lists were using the same display template so I made a new page just to show the item details. In the display template I pointed the item URL (i hijacked the list name and the current item id) to my new page and displayed the item. Let me know if anyone is interested in the whole solution or further elaboration is required.

How can I prevent certain element to get displayed in Google search excerpt?

Currently Google displays elements in the result excerpts that belongs to the functional part of the site. Is there a way to exclude these elements to get crawled/displayed in google?
Like eEdit, eDelete, etc in the example above.
To exclude the pages from Google's index, block them using the Robots.txt file or if it is just the content then use the "rel="nofollow" tag.
Hope this helps.
Update on my particular situation here: I just found out that the frontend code has been generated in a way where the title and the description meta was identical.
Google is smart enough to expect that if a copy is already displayed in the title of the search result there's no reason to add in to the excerpt as well, instead looks for content - believed to be valuable - from the actual page.
Lessons learned:
there's no way to hide elements from google but keep it visible for your users
if you'd like to have control over the content displayed in google searches, avoid using the same copy in your title and description

DataView component in SPD attaches needless strings to field values

In SharePoint Designer I use some lists as sources and then link them together with an operation GetListItems (I fetch items from multiple lists on different site collections for rollup/aggregation):
alt text http://img151.imageshack.us/img151/1807/ss20090428101310.png
Now something is fine as I managed to get the result: alt text http://img410.imageshack.us/img410/4835/ss20090428101013.png
But the strings that are attached to field result (6;#, 2;#) is... disturbing.
How can I get rid from those attached strings? They are not attached to all fields, but to some (important ones):
alt text http://img168.imageshack.us/img168/1647/ss20090428100732.png
Ahh, well usally that happens - you keep searching for answer, then seek for help and find it yourself.
I used substring xsl function, to strip away those first characters. Messy, if i want to add links to that table, but works.
alt text http://img2.imageshack.us/img2/3117/ss20090428102714.png
By the way, the main question how to rollup content from multiple site collections has been journey to me for several days already. If anyone is in the same situation, I recommend (well because I found myself an answer there) these:
How-To Rollup two lists in two site
collections on a page
Or a better way to use for a single
site collection: SharePoint
Customisation Tricks: Use The
SPDataSource, Luke! (Good links
inside that article).
Something I didn't touch, because I
didn't need such an advanced method,
but maybe someone does: Populating
data sources in code

Resources