ขอคำเเนะนำการเขียน selenium ด้วย python สำหรับการเปลี่ยนหน้าเว็บ

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น ภาษา Java ภาษา Python

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
chakirin.bfds
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 783
ลงทะเบียนเมื่อ: 22/12/2020 10:19 am

ขอคำเเนะนำการเขียน selenium ด้วย python สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย chakirin.bfds »

ตอนนี้ผมกำลังเขียน selenium ด้วยภาษา Python เพื่อให้สามารถอ่านกระทู้ของเว็บ viewforum.php?f=338

ในตอนนี้ผมสามารถเขียนโปรเเกรมให้อ่านกระทู้( topic ต่างๆ)ทั้งหมดในหน้าแรกได้เเล้ว ตอนนี้ผมอยากได้คำเเนะนำการเขียนโปรเเกรมในส่วนของการเปิดหน้าถัดไป เพื่อที่สามารถอ่านกระทุ้(topic)ในหน้าถัดไป

ตัวอย่างโค้ดที่ผมลองเขียน

โค้ด: เลือกทั้งหมด

# -*- coding: utf-8 -*-
from selenium import webdriver #อิมพอร์ตโมดูล
import time


driver = webdriver.Firefox()
driver.get("https://www.mindphp.com/forums/viewforum.php?f=338")
time.sleep(2)


xpath_topic = " //a[@class='topictitle'] "
all_ids_topic = driver.find_elements_by_xpath(xpath_topic)
save_link = {}


no = 1
for a in driver.find_elements_by_xpath("//div[@class='pagination']/ul/li"): # element จำนวนหน้า
    print(a)
    for i in all_ids_topic:  #ลูปการเก็บลิงค์และtopic
        save_link[no] = i.get_attribute('href') +' , '+i.text
        #print(no)
        #print(i.text)
        if no == 26: #เมื่อเปิดกระทู้(topic)หน้าเเรกหมด ให้ไปหน้าถัดไป
            driver.find_elements_by_xpath("//li[@class='arrow next']/a[@class='button button-icon-only']")[0].click()  #element ปุ่มของหน้าถัดไป
            no=0
        no+=1
    for n, m in save_link.items():  # ลูปการเปิดลิ้ง
        print(n)
        print(m)
        driver.get(m)
        # driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        time.sleep(2)

Error ที่เกิดขึ้น

โค้ด: เลือกทั้งหมด


/home/com003/PycharmProjects/pythonProject_selenium_test/venv/bin/python /home/com003/PycharmProjects/pythonProject_selenium_test/venv/selenium_openwebtest01.py
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="c2d86dd6-9dbb-444d-a9fe-60b6a510bb6b", element="e1201ceb-4f31-48fb-8630-d46e775fb17a")>
1
https://www.mindphp.com/forums/viewtopic.php?f=338&t=52159&sid=81bf5d776021a4eff9d2271a73d86376 , RoadMap - Mooziicart
2
https://www.mindphp.com/forums/viewtopic.php?f=338&t=53698&sid=81bf5d776021a4eff9d2271a73d86376 , อัพเดด MooZiiCart - อัพเดดข่าวคราวความเครื่อนไหว Change Log / Version History
3
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58392&sid=81bf5d776021a4eff9d2271a73d86376 , ปัญหาที่พบบ่อยในการใช้งาน MooZiicart - Index
4
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71909&sid=81bf5d776021a4eff9d2271a73d86376 , ขอวิธีการหรือขั้นตอนการรันโค้ด selenium สำหรับ ทดสอบ MooZiiCart หน่อยครับ
5
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71678&sid=81bf5d776021a4eff9d2271a73d86376 , เปิดเทมเพจไม่ได้
6
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71270&sid=81bf5d776021a4eff9d2271a73d86376 , มีข้อผิดพลาดเกิดขึ้น 1054 Unknown column 'ordering' in 'field list' แก้ไขยังไงครับ
7
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71358&sid=81bf5d776021a4eff9d2271a73d86376 , เเก้ไขหน้าลงทะเบียน
8
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71331&sid=81bf5d776021a4eff9d2271a73d86376 , อยากอัพ web ขึ้น host ทำไงคะ
9
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71165&sid=81bf5d776021a4eff9d2271a73d86376 , สอบถามการตั้งค่า plugin payment omise
10
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71154&sid=81bf5d776021a4eff9d2271a73d86376 , อยากใส่เมนูข้างๆTemplate ทำยังไงคะ
11
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71034&sid=81bf5d776021a4eff9d2271a73d86376 , เพิ่มเนื้อหาในเมนูแล้วมัน error แก้ยังไงดีคะ
12
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71033&sid=81bf5d776021a4eff9d2271a73d86376 , รายการสินค้าในเว็บไซต์ห่างกันทำไงดีคะ
13
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70904&sid=81bf5d776021a4eff9d2271a73d86376 , ขนาดไซส์กับสีเสื้อให้เลือกต้องเพิ่มส่วนเสริมของ Mooziicart อะไรคะ
14
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70859&sid=81bf5d776021a4eff9d2271a73d86376 , โหลด tempted mooziicart แล้วใช้ไม่ได้ค่ะ
15
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70822&sid=81bf5d776021a4eff9d2271a73d86376 , ใช้ virtuemart บน Joomla 1.5 อัพเกรดมาใช้ MooZiiCart ได้ไหม
16
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70767&sid=81bf5d776021a4eff9d2271a73d86376 , ใช้งาน plugin mzc notify ไม่ได้ครับ
17
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70755&sid=81bf5d776021a4eff9d2271a73d86376 , หน้า admin ของ MooZiicart แก้ template เองได้ไหม
18
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70603&sid=81bf5d776021a4eff9d2271a73d86376 , สอบถามการเปิดใช้งานโมดูล Filters
19
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70562&sid=81bf5d776021a4eff9d2271a73d86376 , สอบถาม วิธี import product เข้า mooziicart
20
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70519&sid=81bf5d776021a4eff9d2271a73d86376 , จะตั้งค่าให้มีระบบเเจ้งการโอนเงินยังไงค่ะ
21
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70507&sid=81bf5d776021a4eff9d2271a73d86376 , ทำเว็บขายของ หลายภาษา เริ่มจากนี่
22
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70497&sid=81bf5d776021a4eff9d2271a73d86376 , สอบถามการเพิ่มสินค้าในบล็อก template ทำยังไงคะ
23
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70430&sid=81bf5d776021a4eff9d2271a73d86376 , อัปเดตเวอร์ชั่น Error
24
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70384&sid=81bf5d776021a4eff9d2271a73d86376 , ติดตั้ง Plugin System MZC Multi Shop ของ mooziicart ไม่ได้
25
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69076&sid=81bf5d776021a4eff9d2271a73d86376 , Module Product Labels แสดงแล้ว error
26
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69946&sid=81bf5d776021a4eff9d2271a73d86376 , ดาวน์โหลด Template Opencart ไม่ได้
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="c2d86dd6-9dbb-444d-a9fe-60b6a510bb6b", element="5a7756d9-4604-4754-9bde-e4a48b08529f")>
Traceback (most recent call last):
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/selenium_openwebtest01.py", line 20, in <module>
    save_link[no] = i.get_attribute('href') +' , '+i.text
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 141, in get_attribute
    self, name)
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Web element reference not seen before: {"element-6066-11e4-a52e-4f735466cecf":"2849c086-500d-47ec-bdec-acfa6160d2b7"}


Process finished with exit code 1

Selection_079.png
จากภาพ สิ่งที่ผมอยากทำก็คือเมื่อโปรเเกรมอ่านกระทู้(topic)หน้าเเรกหมดเเล้ว อยากให้เลื่อนไปหน้าถัดไป(ในโปรแกรมตั้งใจว่าจะใช้วิธีการคลิ๊กปุ๊มที่ลูกศรชี้) เพื่ออ่านกระทู้ที่อยู่ในหน้าถัดไปต่อ
ภาพประจำตัวสมาชิก
chakirin.bfds
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 783
ลงทะเบียนเมื่อ: 22/12/2020 10:19 am

Re: ขอคำเเนะนำการเขียนselenium ด้วยpython สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย chakirin.bfds »

ยังทำไม่ได้เลยครับ
ภาพประจำตัวสมาชิก
MBMoo
PHP VIP Members
PHP VIP Members
โพสต์: 25635
ลงทะเบียนเมื่อ: 04/06/2020 10:05 am

Re: ขอคำเเนะนำการเขียนselenium ด้วยpython สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย MBMoo »

ลองหาจำนวนหน้าก่อนมีกี่หน้า แล้วทำการลูปตามจำนวนหน้า โดยมีลูปย่อยเป็นกระทู้ และเมื่อเปลี่ยนหน้าให้ทำการดึง link หน้ารวมของหน้านั้นๆ มาเก็บไว้ สำหรับไว้ลูปย่อยเสร็จแล้วกลับมาหน้าหลัก เพื่อทำการกด next
ภาพประจำตัวสมาชิก
chakirin.bfds
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 783
ลงทะเบียนเมื่อ: 22/12/2020 10:19 am

Re: ขอคำเเนะนำการเขียนselenium ด้วยpython สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย chakirin.bfds »

ยังทำไม่ได้ครับ ติดตรง เลือก xpath ครับ
ภาพประจำตัวสมาชิก
MBMoo
PHP VIP Members
PHP VIP Members
โพสต์: 25635
ลงทะเบียนเมื่อ: 04/06/2020 10:05 am

Re: ขอคำเเนะนำการเขียนselenium ด้วยpython สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย MBMoo »

ลองทำการ for จาก pagination มันจะมี ul li อยู่ ให้นำการวางบล้อคของมัน แล้วค่อยดัก ว่า อันสุดท้าย ไม่มีให้ กด next ให้ออกจากลูป

โค้ด: เลือกทั้งหมด

driver.find_elements_by_xpath("//div[@class='pagination']/ul/li/a")
ภาพประจำตัวสมาชิก
chakirin.bfds
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 783
ลงทะเบียนเมื่อ: 22/12/2020 10:19 am

Re: ขอคำเเนะนำการเขียนselenium ด้วยpython สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย chakirin.bfds »

อ่านกระทู้ถึงหน้าที่ 2 เเล้วเกิด error ครับ

code

โค้ด: เลือกทั้งหมด

# -*- coding: utf-8 -*-
from selenium import webdriver #อิมพอร์ตโมดูล
import time
import psycopg2 as p
import configparser
con = None
config = configparser.ConfigParser()
config.read('admin.conf')

Username =config['options']['Username']
password =config['options']['password']


driver = webdriver.Firefox()
time.sleep(2)

web_mindphp = 'https://www.mindphp.com/forums/ucp.php?mode=login&redirect=viewforum.php%3Ff%3D338'
driver.get(web_mindphp)
for i in range(4):
            try:
                if driver.find_element_by_name("username"):
                    print('1')
                    #login = wait.until(ec.visibility_of_element_located((By.NAME, "username")))
                    #ActionChains(driver).move_to_element(login).perform()
                    x = driver.find_element_by_name("username")
                    x.clear()
                    x.send_keys(Username)
                    print('2')
                    x = driver.find_element_by_name("password")
                    x.clear()
                    x.send_keys(password)
                    time.sleep(3)
                    driver.find_element_by_name("login").click()
                    time.sleep(3)
                    print('login')
                    break
            except:
                if self.link_click("??????????????"):
                    print("??????????????")
                    break
                pass
            print("??????")
            time.sleep(2)


xpath_page = "//div[@class='pagination']/ul/li"
all_ids_page = driver.find_elements_by_xpath(xpath_page)

xpath_topic = " //a[@class='topictitle'] "
all_ids_topic = driver.find_elements_by_xpath(xpath_topic)
save_link = {}
no = 1
next = 1
for a in driver.find_elements_by_xpath("//div[@class='pagination']/ul/li/a"):
# print(a.get_attribute('class'))
# if a.get_attribute('class') == 'button button-icon-only':
# break
    print(a)
    for i in driver.find_elements_by_xpath(" //a[@class='topictitle'] "):
        save_link[no] = i.get_attribute('href') +' , '+i.text
# i.get_attribute('href')
        print(no)
        print(i.text)

        if next == 26:

            if driver.find_elements_by_xpath("//li[@class='arrow next']"):
                driver.find_elements_by_xpath("//li[@class='arrow next']/a[@class='button button-icon-only']")[0].click()
                next = 0
            else:
                break
            time.sleep(2)
        else:
            no+=1
            next+=1

    # for n, m in save_link.items():  # ลูปการเปิดลิ้ง
    #     print(n)
    #     print(m)
    #     driver.get(m)
    #     # driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    #     time.sleep(2)
print(save_link)





Error
/home/com003/PycharmProjects/pythonProject_selenium_test/venv/bin/python /home/com003/PycharmProjects/pythonProject_selenium_test/venv/find_page.py
1
2
login
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="a08201e2-e282-42ae-be91-2b223ee838fc", element="2f9453d6-0ebd-4b95-8626-b29e25197252")>
1
RoadMap - Mooziicart
2
อัพเดด MooZiiCart - อัพเดดข่าวคราวความเครื่อนไหว Change Log / Version History
3
ปัญหาที่พบบ่อยในการใช้งาน MooZiicart - Index
4
ขอวิธีการหรือขั้นตอนการรันโค้ด selenium สำหรับ ทดสอบ MooZiiCart หน่อยครับ
5
เปิดเทมเพจไม่ได้
6
มีข้อผิดพลาดเกิดขึ้น 1054 Unknown column 'ordering' in 'field list' แก้ไขยังไงครับ
7
เเก้ไขหน้าลงทะเบียน
8
อยากอัพ web ขึ้น host ทำไงคะ
9
สอบถามการตั้งค่า plugin payment omise
10
อยากใส่เมนูข้างๆTemplate ทำยังไงคะ
11
เพิ่มเนื้อหาในเมนูแล้วมัน error แก้ยังไงดีคะ
12
รายการสินค้าในเว็บไซต์ห่างกันทำไงดีคะ
13
ขนาดไซส์กับสีเสื้อให้เลือกต้องเพิ่มส่วนเสริมของ Mooziicart อะไรคะ
14
โหลด tempted mooziicart แล้วใช้ไม่ได้ค่ะ
15
ใช้ virtuemart บน Joomla 1.5 อัพเกรดมาใช้ MooZiiCart ได้ไหม
16
ใช้งาน plugin mzc notify ไม่ได้ครับ
17
หน้า admin ของ MooZiicart แก้ template เองได้ไหม
18
สอบถามการเปิดใช้งานโมดูล Filters
19
สอบถาม วิธี import product เข้า mooziicart
20
จะตั้งค่าให้มีระบบเเจ้งการโอนเงินยังไงค่ะ
21
ทำเว็บขายของ หลายภาษา เริ่มจากนี่
22
สอบถามการเพิ่มสินค้าในบล็อก template ทำยังไงคะ
23
อัปเดตเวอร์ชั่น Error
24
ติดตั้ง Plugin System MZC Multi Shop ของ mooziicart ไม่ได้
25
Module Product Labels แสดงแล้ว error
26
ดาวน์โหลด Template Opencart ไม่ได้
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="a08201e2-e282-42ae-be91-2b223ee838fc", element="9983c781-5e6a-459c-abc7-026757d61dac")>
26
ติดตั้ง Mooziicart v.1.5.17 แล้ว error
27
สอบถามค่ะ Features Component Mooziicart อัปเดทใน joomla ยังไงคะ
28
Module ใน Mooziicart ที่ ไม่สามรถดาวน์โหลดได้
29
Template MZC Megadeal โหลดไม่ได้
30
ติดตั้ง Package Opencart แล้ว alert รหัสผ่านไม่ถูกต้อง
31
หาเมนู Slide-Show ไม่เจอ
32
System requirements สำหรับ MooZiiCart ต้องมีอะไรบ้าง
33
VDO แนะนำ Template จุมล่าสำหรับทำเว็บขายของ ที่ชื่อว่า MooZiiCart Helix - ทำเว็บไซต์อีคอมเมิร์ซ
34
เรื่องการเปลี่ยน Logo ครับ
35
error เวลา บันทึกทุกครั้งที่บันทึกสินค้า Error ใน
36
ขอรบกวนถามววิธีสร้าง
37
สินค้าที่ต้องเลือก attributes ไม่สามารถ add เข้าตะกร้าสินค้าได้ครับ
38
อยากทราบโค้ดที่จะทำให้ลิ้งไปยังหน้าตะกล้าสินค้าของ MooZiiCart ครับ
39
อยากทราบวิธี แสดงจำนวนความเห็นสินค้า ครับ
40
หน้าตั้งค่า Configuration สามารถทำอะไรได้ครับ
41
หน้าตั้งค่านี้ ใช้เรียงลำดับของ Category หน้าเว็บไซต์ได้ไหมครับ
42
แถบ Files ที่อยู่ใน Products เอาไว้ทำอะไรครับ
43
อยากทราบวิธีที่จะทำให้ตัวเลขมีลูกน้ำคั้นครับ
44
เปิดใช้งาน Currencies อย่างไรครับ
45
VDO สอนติดตั้ง ทำเว็บขายของด้วย MooZiiCart
46
สินทรัพย์ถาวร (Fixed Assets) คือ
47
ทำไมเพิ่มรูปแบบการจัดส่งแล้ว ในหน้าเว็บไม่ขึ้นครับ
48
อยากทราบขั้นตอนการสร้างสินค้าแบ่งตามสี ตามขนาด ทำได้มั้ยคะ
49
ต้องการเชื่อมต่อร้านค้ากับ Facebook Page ต้องทำอย่างไร
50
ถ้าเราเปิดขายสินค้ามีการเก็บเงินหน้าปลายทางจะใช้งานอย่างไร
51
ตั้งค่า Email ส่งออกตรงไหนคะ
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="a08201e2-e282-42ae-be91-2b223ee838fc", element="996fff36-b9f1-4c75-b6bd-923e90dde62e")>
52
ติดตั้ง Mooziicart v.1.5.17 แล้ว error
Traceback (most recent call last):
File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/find_page.py", line 60, in <module>
save_link[no] = i.get_attribute('href') +' , '+i.text
File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 141, in get_attribute
self, name)
File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
'args': converted_args})['value']
File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <a class="topictitle" href="./viewtopic.php?f=338&t=69413"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed


Process finished with exit code 1
ภาพประจำตัวสมาชิก
chakirin.bfds
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 783
ลงทะเบียนเมื่อ: 22/12/2020 10:19 am

Re: ขอคำเเนะนำการเขียนselenium ด้วยpython สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย chakirin.bfds »

ตอนนี้เขียนโค้ดให้สามารถอ่านกระทู้ทั้งหน้า ของหน้าที่1 และหน้าที่2 ได้เเล้ว เเต่เมื่ออ่านกระทู้อันสุดท้ายของหน้าที่2 เสร็จ เกิดError โปรเเกรมไม่ยอมเปิดpage หน้าที่ 3
Code ที่เขียน

โค้ด: เลือกทั้งหมด

# -*- coding: utf-8 -*-
from selenium import webdriver #อิมพอร์ตโมดูล
import time
import psycopg2 as p
import configparser
con = None
config = configparser.ConfigParser()
config.read('admin.conf')

Username =config['options']['Username']
password =config['options']['password']


driver = webdriver.Firefox()
time.sleep(2)

web_mindphp = 'https://www.mindphp.com/forums/ucp.php?mode=login&redirect=viewforum.php%3Ff%3D338'
driver.get(web_mindphp)
for i in range(4):
            try:
                if driver.find_element_by_name("username"):
                    print('1')
                    #login = wait.until(ec.visibility_of_element_located((By.NAME, "username")))
                    #ActionChains(driver).move_to_element(login).perform()
                    x = driver.find_element_by_name("username")
                    x.clear()
                    x.send_keys(Username)
                    print('2')
                    x = driver.find_element_by_name("password")
                    x.clear()
                    x.send_keys(password)
                    time.sleep(3)
                    driver.find_element_by_name("login").click()
                    time.sleep(3)
                    print('login')
                    break
            except:
                if self.link_click("??????????????"):
                    print("??????????????")
                    break
                pass
            print("??????")
            time.sleep(2)


#xpath_page = "//div[@class='pagination']/ul/li"
#all_ids_page = driver.find_elements_by_xpath(xpath_page)

xpath_topic = " //a[@class='topictitle'] "
all_ids_topic = driver.find_elements_by_xpath(xpath_topic)
save_link = {}
page_web = ""
no = 1
next = 1
page = 1
for a in driver.find_elements_by_xpath("//div[@class='pagination']/ul/li/a"):
# print(a.get_attribute('class'))
# if a.get_attribute('class') == 'button button-icon-only':
# break
    print(a)
    for i in driver.find_elements_by_xpath(" //a[@class='topictitle'] "):
        save_link[no] = i.get_attribute('href') +' , '+i.text
# i.get_attribute('href')
        print(no)
        print(i.text)

        if next == 26:
            for n, m in save_link.items():  # ลูปการเปิดลิ้ง
                print(n)
                print(m)
                driver.get(m)
            #     #     # driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
            # time.sleep(2)
            # print(save_link)

            if driver.find_elements_by_xpath(" //span[@class='crumb'] "):
                driver.find_elements_by_xpath("//span[@class='crumb']/a[@title='ปัญหาการใช้ MooZiiCart']")[0].click()
                print("กลับมาหน้าหลัก")
                time.sleep(2)

                if driver.find_elements_by_xpath("//li[@class='arrow next']"):
                    page_web = driver.find_elements_by_xpath("//li[@class='arrow next']/a[@class='button button-icon-only']")[0].click()
                        #i.get_attribute('href')
                    page += 1
                    next = 0
                else:
                    break
                time.sleep(2)
            else:
                break
                time.sleep(2)
        else:
            no+=1
            next+=1




error ที่เกิดขึ้น

โค้ด: เลือกทั้งหมด

/home/com003/PycharmProjects/pythonProject_selenium_test/venv/bin/python /home/com003/PycharmProjects/pythonProject_selenium_test/venv/find_page.py
1
2
login
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="e7da147d-dc4c-4400-8bc0-1a381b69e56b", element="79943746-6c31-4a3c-b378-6d4c481a5fff")>
1
RoadMap - Mooziicart
2
อัพเดด MooZiiCart - อัพเดดข่าวคราวความเครื่อนไหว Change Log / Version History
3
ปัญหาที่พบบ่อยในการใช้งาน MooZiicart - Index
4
ขอวิธีการหรือขั้นตอนการรันโค้ด selenium สำหรับ ทดสอบ MooZiiCart หน่อยครับ
5
เปิดเทมเพจไม่ได้
6
มีข้อผิดพลาดเกิดขึ้น 1054 Unknown column 'ordering' in 'field list' แก้ไขยังไงครับ
7
เเก้ไขหน้าลงทะเบียน
8
อยากอัพ web ขึ้น host ทำไงคะ
9
สอบถามการตั้งค่า plugin payment omise
10
อยากใส่เมนูข้างๆTemplate ทำยังไงคะ
11
เพิ่มเนื้อหาในเมนูแล้วมัน error แก้ยังไงดีคะ
12
รายการสินค้าในเว็บไซต์ห่างกันทำไงดีคะ
13
ขนาดไซส์กับสีเสื้อให้เลือกต้องเพิ่มส่วนเสริมของ Mooziicart อะไรคะ
14
โหลด tempted mooziicart แล้วใช้ไม่ได้ค่ะ
15
ใช้ virtuemart บน Joomla 1.5 อัพเกรดมาใช้ MooZiiCart ได้ไหม
16
ใช้งาน plugin mzc notify ไม่ได้ครับ
17
หน้า admin ของ MooZiicart แก้ template เองได้ไหม
18
สอบถามการเปิดใช้งานโมดูล Filters
19
สอบถาม วิธี import product เข้า mooziicart
20
จะตั้งค่าให้มีระบบเเจ้งการโอนเงินยังไงค่ะ
21
ทำเว็บขายของ หลายภาษา เริ่มจากนี่
22
สอบถามการเพิ่มสินค้าในบล็อก template ทำยังไงคะ
23
อัปเดตเวอร์ชั่น Error
24
ติดตั้ง Plugin System MZC Multi Shop ของ mooziicart ไม่ได้
25
Module Product Labels แสดงแล้ว error
26
ดาวน์โหลด Template Opencart ไม่ได้
1
https://www.mindphp.com/forums/viewtopic.php?f=338&t=52159 , RoadMap - Mooziicart
2
https://www.mindphp.com/forums/viewtopic.php?f=338&t=53698 , อัพเดด MooZiiCart - อัพเดดข่าวคราวความเครื่อนไหว Change Log / Version History
3
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58392 , ปัญหาที่พบบ่อยในการใช้งาน MooZiicart - Index
4
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71909 , ขอวิธีการหรือขั้นตอนการรันโค้ด selenium สำหรับ ทดสอบ MooZiiCart หน่อยครับ
5
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71678 , เปิดเทมเพจไม่ได้
6
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71270 , มีข้อผิดพลาดเกิดขึ้น 1054 Unknown column 'ordering' in 'field list' แก้ไขยังไงครับ
7
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71358 , เเก้ไขหน้าลงทะเบียน
8
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71331 , อยากอัพ web ขึ้น host ทำไงคะ
9
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71165 , สอบถามการตั้งค่า plugin payment omise
10
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71154 , อยากใส่เมนูข้างๆTemplate ทำยังไงคะ
11
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71034 , เพิ่มเนื้อหาในเมนูแล้วมัน error แก้ยังไงดีคะ
12
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71033 , รายการสินค้าในเว็บไซต์ห่างกันทำไงดีคะ
13
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70904 , ขนาดไซส์กับสีเสื้อให้เลือกต้องเพิ่มส่วนเสริมของ Mooziicart อะไรคะ
14
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70859 , โหลด tempted mooziicart แล้วใช้ไม่ได้ค่ะ
15
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70822 , ใช้ virtuemart บน Joomla 1.5 อัพเกรดมาใช้ MooZiiCart ได้ไหม
16
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70767 , ใช้งาน plugin mzc notify ไม่ได้ครับ
17
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70755 , หน้า admin ของ MooZiicart แก้ template เองได้ไหม
18
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70603 , สอบถามการเปิดใช้งานโมดูล Filters
19
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70562 , สอบถาม วิธี import product เข้า mooziicart
20
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70519 , จะตั้งค่าให้มีระบบเเจ้งการโอนเงินยังไงค่ะ
21
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70507 , ทำเว็บขายของ หลายภาษา เริ่มจากนี่
22
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70497 , สอบถามการเพิ่มสินค้าในบล็อก template ทำยังไงคะ
23
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70430 , อัปเดตเวอร์ชั่น Error
24
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70384 , ติดตั้ง Plugin System MZC Multi Shop ของ mooziicart ไม่ได้
25
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69076 , Module Product Labels แสดงแล้ว error
26
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69946 , ดาวน์โหลด Template Opencart ไม่ได้
กลับมาหน้าหลัก
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="e7da147d-dc4c-4400-8bc0-1a381b69e56b", element="b523d47d-021c-4a8f-b6f1-0d01ff8cd7cb")>
26
ติดตั้ง Mooziicart v.1.5.17 แล้ว error
27
สอบถามค่ะ Features Component Mooziicart อัปเดทใน joomla ยังไงคะ
28
Module ใน Mooziicart ที่ ไม่สามรถดาวน์โหลดได้
29
Template MZC Megadeal โหลดไม่ได้
30
ติดตั้ง Package Opencart แล้ว alert รหัสผ่านไม่ถูกต้อง
31
หาเมนู Slide-Show ไม่เจอ
32
System requirements สำหรับ MooZiiCart ต้องมีอะไรบ้าง
33
VDO แนะนำ Template จุมล่าสำหรับทำเว็บขายของ ที่ชื่อว่า MooZiiCart Helix - ทำเว็บไซต์อีคอมเมิร์ซ
34
เรื่องการเปลี่ยน Logo ครับ
35
error เวลา บันทึกทุกครั้งที่บันทึกสินค้า Error ใน
36
ขอรบกวนถามววิธีสร้าง
37
สินค้าที่ต้องเลือก attributes ไม่สามารถ add เข้าตะกร้าสินค้าได้ครับ
38
อยากทราบโค้ดที่จะทำให้ลิ้งไปยังหน้าตะกล้าสินค้าของ MooZiiCart ครับ
39
อยากทราบวิธี แสดงจำนวนความเห็นสินค้า ครับ
40
หน้าตั้งค่า Configuration สามารถทำอะไรได้ครับ
41
หน้าตั้งค่านี้ ใช้เรียงลำดับของ Category หน้าเว็บไซต์ได้ไหมครับ
42
แถบ Files ที่อยู่ใน Products เอาไว้ทำอะไรครับ
43
อยากทราบวิธีที่จะทำให้ตัวเลขมีลูกน้ำคั้นครับ
44
เปิดใช้งาน Currencies อย่างไรครับ
45
VDO สอนติดตั้ง ทำเว็บขายของด้วย MooZiiCart
46
สินทรัพย์ถาวร (Fixed Assets) คือ
47
ทำไมเพิ่มรูปแบบการจัดส่งแล้ว ในหน้าเว็บไม่ขึ้นครับ
48
อยากทราบขั้นตอนการสร้างสินค้าแบ่งตามสี ตามขนาด ทำได้มั้ยคะ
49
ต้องการเชื่อมต่อร้านค้ากับ Facebook Page ต้องทำอย่างไร
50
ถ้าเราเปิดขายสินค้ามีการเก็บเงินหน้าปลายทางจะใช้งานอย่างไร
51
ตั้งค่า Email ส่งออกตรงไหนคะ
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="e7da147d-dc4c-4400-8bc0-1a381b69e56b", element="a82de278-519a-46de-b776-ebc528f7c69b")>
52
ติดตั้ง Mooziicart v.1.5.17 แล้ว error
1
https://www.mindphp.com/forums/viewtopic.php?f=338&t=52159 , RoadMap - Mooziicart
2
https://www.mindphp.com/forums/viewtopic.php?f=338&t=53698 , อัพเดด MooZiiCart - อัพเดดข่าวคราวความเครื่อนไหว Change Log / Version History
3
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58392 , ปัญหาที่พบบ่อยในการใช้งาน MooZiicart - Index
4
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71909 , ขอวิธีการหรือขั้นตอนการรันโค้ด selenium สำหรับ ทดสอบ MooZiiCart หน่อยครับ
5
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71678 , เปิดเทมเพจไม่ได้
6
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71270 , มีข้อผิดพลาดเกิดขึ้น 1054 Unknown column 'ordering' in 'field list' แก้ไขยังไงครับ
7
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71358 , เเก้ไขหน้าลงทะเบียน
8
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71331 , อยากอัพ web ขึ้น host ทำไงคะ
9
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71165 , สอบถามการตั้งค่า plugin payment omise
10
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71154 , อยากใส่เมนูข้างๆTemplate ทำยังไงคะ
11
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71034 , เพิ่มเนื้อหาในเมนูแล้วมัน error แก้ยังไงดีคะ
12
https://www.mindphp.com/forums/viewtopic.php?f=338&t=71033 , รายการสินค้าในเว็บไซต์ห่างกันทำไงดีคะ
13
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70904 , ขนาดไซส์กับสีเสื้อให้เลือกต้องเพิ่มส่วนเสริมของ Mooziicart อะไรคะ
14
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70859 , โหลด tempted mooziicart แล้วใช้ไม่ได้ค่ะ
15
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70822 , ใช้ virtuemart บน Joomla 1.5 อัพเกรดมาใช้ MooZiiCart ได้ไหม
16
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70767 , ใช้งาน plugin mzc notify ไม่ได้ครับ
17
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70755 , หน้า admin ของ MooZiicart แก้ template เองได้ไหม
18
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70603 , สอบถามการเปิดใช้งานโมดูล Filters
19
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70562 , สอบถาม วิธี import product เข้า mooziicart
20
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70519 , จะตั้งค่าให้มีระบบเเจ้งการโอนเงินยังไงค่ะ
21
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70507 , ทำเว็บขายของ หลายภาษา เริ่มจากนี่
22
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70497 , สอบถามการเพิ่มสินค้าในบล็อก template ทำยังไงคะ
23
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70430 , อัปเดตเวอร์ชั่น Error
24
https://www.mindphp.com/forums/viewtopic.php?f=338&t=70384 , ติดตั้ง Plugin System MZC Multi Shop ของ mooziicart ไม่ได้
25
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69076 , Module Product Labels แสดงแล้ว error
26
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69417 , ติดตั้ง Mooziicart v.1.5.17 แล้ว error
27
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69413 , สอบถามค่ะ Features Component Mooziicart อัปเดทใน joomla ยังไงคะ
28
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69075 , Module ใน Mooziicart ที่ ไม่สามรถดาวน์โหลดได้
29
https://www.mindphp.com/forums/viewtopic.php?f=338&t=68851 , Template MZC Megadeal โหลดไม่ได้
30
https://www.mindphp.com/forums/viewtopic.php?f=338&t=66548 , ติดตั้ง Package Opencart แล้ว alert รหัสผ่านไม่ถูกต้อง
31
https://www.mindphp.com/forums/viewtopic.php?f=338&t=67105 , หาเมนู Slide-Show ไม่เจอ
32
https://www.mindphp.com/forums/viewtopic.php?f=338&t=66562 , System requirements สำหรับ MooZiiCart ต้องมีอะไรบ้าง
33
https://www.mindphp.com/forums/viewtopic.php?f=338&t=62006 , VDO แนะนำ Template จุมล่าสำหรับทำเว็บขายของ ที่ชื่อว่า MooZiiCart Helix - ทำเว็บไซต์อีคอมเมิร์ซ
34
https://www.mindphp.com/forums/viewtopic.php?f=338&t=62156 , เรื่องการเปลี่ยน Logo ครับ
35
https://www.mindphp.com/forums/viewtopic.php?f=338&t=61709 , error เวลา บันทึกทุกครั้งที่บันทึกสินค้า Error ใน
36
https://www.mindphp.com/forums/viewtopic.php?f=338&t=61701 , ขอรบกวนถามววิธีสร้าง
37
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60832 , สินค้าที่ต้องเลือก attributes ไม่สามารถ add เข้าตะกร้าสินค้าได้ครับ
38
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60830 , อยากทราบโค้ดที่จะทำให้ลิ้งไปยังหน้าตะกล้าสินค้าของ MooZiiCart ครับ
39
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60592 , อยากทราบวิธี แสดงจำนวนความเห็นสินค้า ครับ
40
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60662 , หน้าตั้งค่า Configuration สามารถทำอะไรได้ครับ
41
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60654 , หน้าตั้งค่านี้ ใช้เรียงลำดับของ Category หน้าเว็บไซต์ได้ไหมครับ
42
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60628 , แถบ Files ที่อยู่ใน Products เอาไว้ทำอะไรครับ
43
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60619 , อยากทราบวิธีที่จะทำให้ตัวเลขมีลูกน้ำคั้นครับ
44
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60553 , เปิดใช้งาน Currencies อย่างไรครับ
45
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60576 , VDO สอนติดตั้ง ทำเว็บขายของด้วย MooZiiCart
46
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60468 , สินทรัพย์ถาวร (Fixed Assets) คือ
47
https://www.mindphp.com/forums/viewtopic.php?f=338&t=60370 , ทำไมเพิ่มรูปแบบการจัดส่งแล้ว ในหน้าเว็บไม่ขึ้นครับ
48
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58393 , อยากทราบขั้นตอนการสร้างสินค้าแบ่งตามสี ตามขนาด ทำได้มั้ยคะ
49
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58709 , ต้องการเชื่อมต่อร้านค้ากับ Facebook Page ต้องทำอย่างไร
50
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58721 , ถ้าเราเปิดขายสินค้ามีการเก็บเงินหน้าปลายทางจะใช้งานอย่างไร
51
https://www.mindphp.com/forums/viewtopic.php?f=338&t=58440 , ตั้งค่า Email ส่งออกตรงไหนคะ
52
https://www.mindphp.com/forums/viewtopic.php?f=338&t=69417 , ติดตั้ง Mooziicart v.1.5.17 แล้ว error
กลับมาหน้าหลัก
Traceback (most recent call last):
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/find_page.py", line 62, in <module>
    save_link[no] = i.get_attribute('href') +' , '+i.text
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 141, in get_attribute
    self, name)
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
    'args': converted_args})['value']
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/com003/PycharmProjects/pythonProject_selenium_test/venv/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Web element reference not seen before: {"element-6066-11e4-a52e-4f735466cecf":"057485f5-daa8-41e8-b1fc-3e34be712454"}


Process finished with exit code 1

บุคคลทั่วไป

Re: ขอคำเเนะนำการเขียน selenium ด้วย python สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย บุคคลทั่วไป »

ใครมีตัวสมบูรณ์บ้างโค้ดอ่านข้อมูลเว็บบอร์ด
บุคคลทั่วไป

Re: ขอคำเเนะนำการเขียน selenium ด้วย python สำหรับการเปลี่ยนหน้าเว็บ

โพสต์ที่ยังไม่ได้อ่าน โดย บุคคลทั่วไป »

ม.เดียวกันเปล่าเนี่ย การบ้านแบบเดียวกันเลย
ขอหน่อยๆ
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 3