i am trying to automate WhatsApp, following steps are to be done,problem is in point 4:
launch whatsapp.web
scan QR code:
search contact
clicke on the searched contact, tried the code but didn't show any output.
folllowing is my code:
search_box=driver.find_element_by_xpath('//*[#id="side"]/div[1]/div/label').click() search_box_input=driver.find_element_by_xpath('//*[#id="side"]/div[1]/div/label/div/div[2]') search_box_input.send_keys('racpient name')
after it how to click on searched contact?
tried code for clicking searched contact is :
'
target = "racipient"
input('Press Enter after scanning QR Code...')
TargetXML = driver.find_element_by_xpath('//span[#title = " {}"]'.format(target))
TargetXML.click() '
image is attached,how to do step 2 (click on search contact) in labeled image
Related
I'm having a hard time coming up with a solution. I'm writing code in Python using the Selenium library to pull reports from a site we utilize. In order to access the reports, it has to click on a link to expand so the code can find the report names. The issue I'm running into is the code is running fine and clicking on the link, but the link isn't expanding to reveal the reports. Debugging is saying that the link is found and clicked with a post response of 200, but nothing is happening. Due to the nature of the response code saying everything is fine, I'm at a loss of why the folder isn't expanding. Due to the nature of the site, I cannot share too much but have attached my code that I can share along with screenshots.
wait = WebDriverWait(driver_chrom, 30)
def Try_Wait(args, thing_string):
try:
wait.until(EC.presence_of_element_located(args))
logger_write.debug("found element "+thing_string)
#print("found args for ", thing_string)
return
except:
Exit_LogOut()
driver_chrom.quit()
sys.exit()
def Button_Click(args, thing_string):
try:
driver_chrom.find_element(*args).click()
logger_write.debug("Found button click"+thing_string)
#print('clicking button for ', thing_string)
return
except:
#print('did not click button ', thing_string)
logger_write.error("Did not find button "+thing_string)
return
thing_string = 'Opening folder for reports'
Try_Wait((By.XPATH,'//div[#id="folder1"]/table/tbody/tr//td[a[starts-with(#href, "javascript:clickOnNode(") and contains(#href, "1") and contains(text(),"Standard")]]'), thing_string)
Button_Click((By.XPATH,'//div[#id="folder1"]/table/tbody/tr//td[a[starts-with(#href, "javascript:clickOnNode(") and contains(#href, "1") and contains(text(),"Standard")]]'), thing_string)
This is what it looks like after code above runs
This is what it should look like so that reports are loaded into the html
Here is the inspect screenshot:
Try following xpath should work for you.
//a[text()="Standard"]
Instead this
//div[#id="folder1"]/table/tbody/tr//td[a[starts-with(#href, "javascript:clickOnNode(") and contains(#href, "1") and contains(text(),"Standard")]]
Or use Link_Text since it is anchor rag
Try_Wait((By.LINK_TEXT ,"Standard"), thing_string)
Button_Click((By.LINK_TEXT ,"Standard"), thing_string)
Hi team,
I have created program where I need to upload file. By clicking on "Upload" , I reach to this window. but here I stuck now. I need to enter path automatically. please help if you have any examples.
driver1 = webdriver.Chrome(executable_path= r'C:\\Users\\Ast1\\Desktop\\chromedriver.exe')
Sharepoint ="https://ast.sharepoint.com/sites/ExtTeam_GPS/Shared%20Documents/Forms/AllItems.aspx?viewid=3638f543%2D486c%2D4bca%2D85a7%2D8d86da0a8eb5&id=%2Fsites%2FExtTeam%5FNO%2FShared%20Documents%2FPowerBI%20Datasets"
driverLink= Sharepoint
driver1.get(driverLink)
Em = WebDriverWait(driver1,120).until(EC.presence_of_element_located((By.ID,'i0116')))
Em.send_keys("astemp1#ast.com")
elm =WebDriverWait(driver1,120).until(EC.presence_of_element_located((By.ID,'idSIButton9')))
elm.click()
driver1.implicitly_wait(100)
#elm1 = WebDriverWait(driver1,100).until(EC.presence_of_element_located((By.PARTIAL_LINK_TEXT,'Upload')))
elm2 = driver1.find_element_by_xpath('//*[#id="appRoot"]/div[1]/div[2]/div[3]/div/div[2]/div[2]/div[2]/div[1]/div/div/div/div/div/div/div[1]/div[2]/button')
elm2.click()
driver1.implicitly_wait(20)
elm3 = driver1.find_element_by_name('Files')
elm3.click()
driver1.implicitly_wait(20)
#Follwing code is not working.
Elm4 = driver1.find_element(By.ID('File name'))
Elm4.send_keys(r'C:\A1\AA1\M1\Input\TblGpsNew.xlsx')
#driver1.implicitly_wait(100)
If the page where you have the upload button (entire page), if the below xpath
//input[#type='file']
exists at least one time 1/1 matches then, you can directly send the keys.
Explicitly no need to click on upload button and then interact with the windows pop up.
driver1.find_element(By.XPATH("//input[#type='file']")).send_keys("C:\A1\AA1\M1\Input\TblGpsNew.xlsx")
I am working on creating a small program using Python that will decompile a captcha This is a picture of the captcha types that I want to solve
The problem is when you enter the image link to download it, it has changed to another image:
https://reg.nid-moi.gov.iq/captcha/default?5wyju6xn
from python_anticaptcha import AnticaptchaClient, ImageToTextTask
api_key = 'my_api_key'
captcha_fp = open('default.png', 'rb')
client = AnticaptchaClient(api_key)
task = ImageToTextTask(captcha_fp)
job = client.createTask(task)
job.join()
print (job.get_captcha_text())
Having some trouble with a project and hopefully someone can help! I'm trying to take extracted text from tesseract OCR and use that text as the search query of Google Chrome searches. My shell script can extract the text and launch Chrome, but I cant figure out how to send the text to the searchbar of chrome. Below are some pictures of my script. I'm extremely new to coding, so any help is appreciated.
Shell script
echo "Realtime Screen OCR"
while true
do
echo "Waiting for trigger"
read
screencapture -R31,205,420,420 screens.png
tesseract screens.png ocr
OCR=`cat ocr.txt`
python3 launch1.py $OCR
##/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $OCR
echo "Opened Chrome...waiting for next question"
done
Python Script
import urllib.parse
search_query = input("enter search query")
query_encoded = urllib.parse.quote_plus(search_query)
google_search_url = "http://www.google.com/search?q=" +
format(query_encoded)
import webbrowser
webbrowser.open(google_search_url)
It appears to me that the only step you're missing is grabbing the text in your Python code and passing it into the search query. You can do this using sys. In this example we replace the user-inputted text with retrieving the argument from the command line, assuming that this is what you're trying to do.
import urllib.parse
import sys
search_query = sys.argv[1]
query_encoded = urllib.parse.quote_plus(search_query)
google_search_url = "http://www.google.com/search?q=" +
format(query_encoded)
import webbrowser
webbrowser.open(google_search_url)
This is my first topic and question. I'm trying to write a script in Python(Pycharm) which help me log on to SAP via Citrix from the browser level. My problem is that I can't go through the window that pops out:
Open URL: xxx Always open this type of links in the associated application.
My script:
*imports that I need*
driver = webdriver.Chrome('C:\User\Chromium\chromedriver.exe')
driver.maximize_window()
driver.get('https://XYZ.dk')
Detect_Reciver = driver.find_element_by_xpath('//*[#id="protocolhandler-welcome"]/div/div/div/div/a')
if Detect_Reciver == Detect_Reciver:
Detect_Reciver.click()
time.sleep(2)
The problem appears here, after loading on a new page, the "Open URL: xxx Always open this type of links in the associated application." pops out, and I want to Press Enter or Escape by Python. Send_keys(keys.ENTER/ESCAPE) doesn't work.
enter image description here
Can you help me out :)?